memory型表支持Hash索引
来源:互联网 发布:mac 照片 储存 编辑:程序博客网 时间:2024/06/03 13:59
mysql> create table test_memory
-> (i smallint not null auto_increment,
-> name varchar(10),primary key(i))
-> engine=memory charset=gbk;
Query OK, 0 rows affected (0.01 sec)
mysql> SHOW INDEX FROM test_memory;
+————-+————+———-+————–+————–+——–+——+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+————-+————+———-+——————+———-+——–+——+
| test_memory | 0 | PRIMARY | 1 | i | NULL | 0 | NULL | NULL | | HASH | |
+————-+————+———-+——————+———-+——–+——+-
1 row in set (0.02 sec)
memory型表创建的PK,默认的就是hash索引
mysql> explain select * from test_memory where i>1 /G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: test_memory
type: ALL
possible_keys: PRIMARY
key: NULL
key_len: NULL
ref: NULL
rows: 2
Extra: Using where
1 row in set (0.04 sec)
mysql> explain select * from test_memory where i=1 /G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: test_memory
type: const
possible_keys: PRIMARY
key: PRIMARY
key_len: 2
ref: const
rows: 1
Extra:
1 row in set (0.01 sec)
从这里两个对比中发现,hash index支持”=”等式查询,不支持”>=”,”<=”,”<”,”>”,”<>”,”between”,”!=”,”like”
hash索引的创建:
mysql> create table test_memory_sp
-> (i smallint not null,
-> name varchar(10))
-> engine=memory charset=gbk;
Query OK, 0 rows affected (0.10 sec)
mysql> create index ind_hash using hash on test_memory_sp(i);
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> insert into test_memory_sp values(1,’A');
Query OK, 1 row affected (0.00 sec)
mysql> insert into test_memory_sp values(1,’B');
Query OK, 1 row affected (0.00 sec)
mysql> insert into test_memory_sp values(2,’C');
Query OK, 1 row affected (0.00 sec)
mysql> explain select * from test_memory_sp where i=1 /G;
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: test_memory_sp
type: ref
possible_keys: ind_hash
key: ind_hash
key_len: 2
ref: const
rows: 2
Extra:
1 row in set (0.00 sec)
- memory型表支持Hash索引
- mysql InnoDB引擎支持hash索引吗
- MySQL8.0的InnoDB和MyISAM是否支持hash索引
- Hash 索引
- 【索引分类】Hash索引
- mysql memory 索引
- Hash索引和BTree索引
- Hash索引和BTREE索引
- Hash索引和BTREE索引
- 倒排索引,hash索引
- Hash索引和BTree索引
- Btree索引和Hash索引
- Hash索引和BTree索引
- MySQL hash索引
- mysql hash 索引
- Mysql Hash索引
- mysql 自定义hash索引
- 数据库的hash索引
- mysql 查看索引使用情况
- 利用Visual Studio 2008 GDI+实现的txt小说阅读器
- 经典批处理教程
- mysql索引的一个技巧
- Javascript中最常用的55个经典技巧
- memory型表支持Hash索引
- 基于Hibernate3.2 Hibernate tools 的使用
- MySQL里建立索引应该考虑数据库引擎的类型
- MySQL MyIsam 存储引擎索引长度限制测试记录
- Phoenix BIOS Int 13h 入口
- php 访问控制
- 修复损坏的MyISAM表
- Excel cell 内公式不自动计算解决方法
- struts-default.xml文档解释