`

B-tree索引和hash索引

阅读更多
A B-tree 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
引用
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.)

Hash index——problems
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.
Choosing An index
An index should support a query of the application that has the most impact on performance
Choice based on frequency of invocation execution time acquired lockstable size

参考资料:
http://dev.mysql.com/doc/refman/5.5/en/index-btree-hash.html
http://stackoverflow.com/questions/7306316/btree-vs-hashtable
分享到:
评论

相关推荐

    MySQL Hash索引和B-Tree索引的区别

    MySQL Hash索引结构的特殊性,其检索效率非常高,索引的检索可以一次定位,不像B-Tree 索引需要从根节点到枝节点,最后才能访问到页节点这样多次的IO访问,所以 Hash 索引的查询效率要远高于 B-Tree 索引。...

    PostgreSQL教程(八):索引详解

     PostgreSQL提供了多 种索引类型:B-Tree、Hash、GiST和GIN,由于它们使用了不同的算法,因此每种索引类型都有其适合的查询类型,缺省时,CREATE INDEX命令将创建B-Tree索引。    1. B-Tree:  代码如下:  ...

    MYSQL索引

    mysql中索引是在存储引擎层而不是服务器层实现的B-Tree索引B-Tree通常意味着所有的值都是按顺序存储的,并且每一个叶子页到根的距离相同。图中根节点没有画出来。B-Tree对索引列是顺序组织存储的,索引很适合查找...

    Mysql中的Btree与Hash索引比较

    mysql最常用的索引结构是btree(O(log(n))),但是总有一些情况下我们为了更好的性能希望能使用别的类型的索引。hash就是其中一种选择,例如我们在通过用户名检索用户id的时候,他们总是一对一的...B-Tree索引可以被用

    UTR*-Tree:受限网络中移动对象不确定轨迹索引模型 (2010年)

    将移动对象位置则作为动态信息采用R*-Tree和Hash数组协同管理。借助该结构,移动对象数据库不仅可以快速地处理对移动对象过去可能位置的查询,而且能够对其现在及将来的可能位置进行高效的查询处理。实验结果表明同...

    Oracle 11g Release (11.1) 索引底层的数据结构

    本文内容 B-树(B-tree) 散列(Hash) k-d 树(k-d tree) 点四叉树(Point Quadtree) 本文介绍关于 Oracle 索引的结构。大概了解 Oracle 索引底层的数据结构,从而更好地理解 Oracle 索引对增、删、改、查的性能...

    1,int(20)中20的涵义 2,为什么索引结构默认使用B+Tree,而不是Hash,二叉树,红黑树? 3、MySQL里记录

    2,为什么索引结构默认使用B+Tree,而不是Hash,二叉树,红黑树? 3、MySQL里记录货币用什么字段类型好 4、数据库自增主键可能遇到什么问题。 5、从锁的类别角度讲,MySQL都有哪些锁呢? 6、索引失效情况? 7、优化...

    索引的数据结构.pdf

    b-tree:⼀个 m 阶的B树满⾜以下条件: 每个结点⾄多拥有m棵⼦树; 除了根结点以外,其余每个分⽀结点⾄少拥有 m/2 棵⼦树; 根结点⾄少拥有两颗⼦树(存在⼦树的情况下); 所有的叶结点都在同⼀层上,其可以看作...

    分布式图数据库NebulaGraph的Index实践

    不同的数据库系统有不同的排序结构,目前常见的索引实现类型如B-Treeindex、B+-Treeindex、B*-Treeindex、Hashindex、Bitmapindex、Invertedindex等等,各种索引类型都有各自的排序算法。虽然索引可以带来更高的查询...

    Mysql覆盖索引详解

    2、Hash 和full-text索引不存储值,因此MySQL只能使用B-TREE 3、并且不同的存储引擎实现覆盖索引都是不同的 4、并不是所有的存储引擎都支持它们 5、如果要使用覆盖索引,一定要注意SELECT 列表值取出需要的列,

    timesten优化

    Hash indexes(比较快的exact match lookup) T-tree index(适用于exact match & range lookup) Primary Key 自动创建 Hash index Hash index :Pages = Rows expected / 256 Full table Scan 最好创建一个T-tree ...

    海量数据库解决方案_韩国_李华植

    3.2.4.3 与b-tree索引相结合的执行计划184 3.2.5 其他特殊处理的执行计划185 3.2.5.1 递归展开(recursive implosion)执行计划186 3.2.5.2 修改子查询执行计划191 3.2.5.3 特殊类型的执行计划193 3.3 执行计划的控制...

    海量数据库解决方案_韩国_李华植_Part02

    3.2.4.3 与b-tree索引相结合的执行计划184 3.2.5 其他特殊处理的执行计划185 3.2.5.1 递归展开(recursive implosion)执行计划186 3.2.5.2 修改子查询执行计划191 3.2.5.3 特殊类型的执行计划193 3.3 执行计划的控制...

    怎样正确创建MySQL索引的方法详解

    索引类似大学图书馆建书目索引,可以提高数据检索的效率,降低...Mysql索引主要有两种结构:B+Tree索引和Hash索引。我们平常所说的索引,如果没有特别指明,一般都是指B树结构组织的索引(B+Tree索引)。索引如图所示:

    基于双树双索引结构的移动查询方法 (2008年)

    双树双索引结构利用网格划分思想构建空间分割树,实现对现有GG TPR-tree查询结构的拓展,并结合GG TPR-tree索引及建立于内存中的Hash索引以满足各种类型的移动查询请求。仿真实验表明,在回答受限范围内海量移动对象...

    MySQL索引和引擎

    一.索引 ...B-Tree … 索引案例 比如现在,MySQL中有这么一张表 test,需要进行查询(select * from test where id = 5) id value 1 12 2 23 3 232 4 121 5 45 6 67 7 55 在不

    mysql索引和explain的详解

    MyISAM和InnoDB存储引擎:只支持B+ TREE索引, 也不能够更换 MEMORY/HEAP存储引擎:支持HASH和BTREE索引 B树图示 B树是为了磁盘或其它存储设备设计的一种多叉(下面你会看到,相对于二叉,B树每个内结点有多个分支,...

    面试mysql 之索引 锁 事物

    什么是索引,index 索引:是帮助高效获取数据的数据结构 索引也可能是一个文件 那么多存储结构 hash map 红黑树 二叉树等 为什么mysql底层要用B+ tree实现?

Global site tag (gtag.js) - Google Analytics