create table t1(x char(10), y char(10), key hs using hash(x,y)) engine=myisaminsert 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索引这是怎么了, 支持范围查找了????????????????????????????
1 SIMPLE t1 index hs hs 62 2 Using where; Using index
请问hash索引这是怎么了, 支持范围查找了????????????????????????????
解决方案 »
- 只显示同一品牌今天最后一条数据,和前一天最后一条数据,将他们在一行中显示。
- 如何用sql在一个表内完成按字段值重复记录拆分成多个表
- 各位 这个SQl语句应该如何写会更加高效?
- 【Mysql-6.0.9】 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
- 新换了linux和nginx服务器,报2013错误了。
- mysql建表怎么建
- 我刚开始学,请您帮帮忙,谢谢!
- 请问怎么在Java里获得MySQL的所有表???
- 各位如何在win2000下安装mysql的jdbc驱动,急
- 单表的汇总查询(计算比值)
- 关于mysql procedure嵌套游标
- Mysql的Select变量问题
显然扫描hash索引要比扫描表代价小
但是describe就是很明确的提示使用了hs这个索引啊
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索引,一切都好解释了吧?