B-tree索引和hash索引

A [b]B-tree[/b] index can be used for column comparisons in expressions that use the =, >, >=, <, <=, or BETWEEN operators.
1、The index also can be used for LIKE comparisons if the argument to LIKE is a constant string that does not start with a wildcard character.
2、Supports equality and range searched,multiple attribute keys and partial key searches
3、Either a separate index or the basis for a storage structure
4、Responds to dynamic changes in the table
[quote]Hash indexes have some what different characteristics from those just discussed:
*
They are used only for equality comparisons that use the = or <=> operators (but are very fast). They are not used for comparison operators such as < that find a range of values. Systems that rely on this type of single-value lookup are known as “key-value stores”; to use MySQL for such applications, use hash indexes wherever possible.
*
The optimizer cannot use a hash index to speed up ORDER BY operations. (This type of index cannot be used to search for the next entry in order.)
*
MySQL cannot determine approximately how many rows there are between two values (this is used by the range optimizer to decide which index to use). This may affect some queries if you change a MyISAM table to a hash-indexed MEMORY table.
*
Only whole keys can be used to search for a row. (With a B-tree index, any leftmost prefix of the key can be used to find rows.) [/quote]
[b]Hash index——problems[/b]
1、Does not support range search
2、Although it supports multiple attribute keys,it does not support partial key search.
3、Dynamically growing files produce overflow chains,which negate the efficiency of the algorithm.
[b]Choosing An index[/b]
An index should support a query of the application that has the most impact on performance
Choice based on [b]frequency of invocation[/b]、[b] execution time [/b]、[b]acquired locks[/b]、 [b]table size[/b]

参考资料:
http://dev.mysql.com/doc/refman/5.5/en/index-btree-hash.html
http://stackoverflow.com/questions/7306316/btree-vs-hashtable
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值