Chinaunix

标题: Hash indexes [打印本页]

作者: xfwduke    时间: 2011-12-21 08:42
标题: Hash indexes

A hash index is built on a hash table and is useful only for exact lookups that use every column in the index.

It stores the hash codes in the index and stores a pointer to each row in a hash table.

hash索引只能用于精确查询。

hash索引存储了hash codekey)和指向对应列的指针。

In MySQL, only the Memory storage engine supports explicit hash indexes. They are the default index type for Memory tables,though Memory tables can have B-Tree indexes too. The Memory engine supports nonunique hash indexes, which is unusual in the database world. If multiple values have the same hash code, the index will store their row pointers in the same hash table entry, using a linked list.

MySQL中只有Memory引擎表支持hash索引——这也是Memory表的默认索引——所以Memory表同时支持hash索引和B-Tree索引。Memory表的hash索引允许键值冲突,当多列的键值相同时,指向这些列的指针会存在同一个hash表入口,并组织成链表方式。

Because the indexes themselves store only short hash values, hash indexes are very compact. The hash value's length doesn't depend on the type of the columns you index——a hash index on a TINYINT will be the same size as a hash index on a large character column.

hash索引的key长度都是一样的,而且都非常短。key长度和索引列类型无关——TINYINT类型和字符类型列的hash索引key长是一样的。

Hash 索引的一些细则:





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2