Skip to content

Commit

Permalink
add new files
Browse files Browse the repository at this point in the history
  • Loading branch information
LYDongD committed Aug 1, 2019
1 parent 8e72d01 commit 22811b5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
* [多数据源](dev-ops/mysql/multi-db.md)
* [存储过程](dev-ops/mysql/stored_procedure.md)
* [oracle常用SQL](dev-ops/mysql/oracle.md)
* [索引](dev-ops/mysql/index.md)
* [计算机原理](dev-ops/computer/README.md)
* [CPU](dev-ops/computer/cpu.md)
* [网络](dev-ops/computer/net.md)
Expand Down
29 changes: 29 additions & 0 deletions dev-ops/mysql/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## 索引

### 如何在创建索引时指定索引类型?

mysql支持两种索引:

* B+ tree
* hash

通过以下语句指定索引类型

```
create index dx_username using hash on tb_user(username);
```

然而,innodb并不支持hash索引,如果坚持要指定hash类型,mysql会返回错误:

This storage engine does not support the HASH index algorithm, storage engine default was used instead.

### hash 索引的使用场景

hash索引用hash字典实现,读写速度都很快,但是无法实现范围查询,例如>, between等操作符相关的query

因此,hash索引适合key-value数据库,如果有人拿mysql做key-value存储的话

B+ tree 叶子节点是双向链表,利于范围查询和排序等


0 comments on commit 22811b5

Please sign in to comment.