• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

mysql中hash索引存在的奇怪的有关问题

mysql 搞代码 7年前 (2018-06-02) 169次浏览 已收录 0个评论

mysql中hash索引存在的奇怪的问题
create table t1(x char(10), y char(10), key hs using hash(x,y)) engine=myisam

insert into t1 values(‘fdsfd’, ‘gdfas’),(‘fds’, ‘gasd’);

describe select * from t1 where x>’fd’

结果为

1 SIMPLE t1 index hs hs 62 2 Using where; Using index

请问hash索引这是怎么了, 支持范围查找了????????????????????????????

——解决方案——————–
mysql> create table t1(x char(10), y char(10), key hs using hash(x,y)) engine=myisam;
Query OK, 0 rows affected (0.07 sec)
 
mysql> insert into t1 values(‘fdsfd’, ‘gdfas’),(‘fds’, ‘gasd’);
Query OK, 2 rows affected (0.17 sec)
Records: 2 Duplicates: 0 Warnings: 0
 
mysql> show index from t1;
+——-+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+——-+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+
| t1 | 1 | hs | 1 | x | A | NULL | NULL | NULL | YES | BTREE | | |
| t1 | 1 | hs | 2 | y | A | NULL | NULL | NULL | YES | BTREE | | |
+——-+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+
2 rows in set (0.00 sec)

MyISAM 用的是B-TREE索引,不支持显式的hash索引,但是可以内部使用自适应HASH索引。memory引擎默认是hash索引。

如果是B-TREE索引,一切都好解释了吧?


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:mysql中hash索引存在的奇怪的有关问题

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址