Skip to content

Commit 4e4ef71

Browse files
author
chengwei2
committed
update
1 parent c30cdaa commit 4e4ef71

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

_posts/2017-10-22-数据库索引技术.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,19 @@ title的选择性不足0.0001(精确值为0.00001579),所以实在没有
192192

193193
![索引选择性与前缀索引](/img/database-index/database-index-23.png)
194194

195-
如果频繁按名字搜索员工,这样显然效率很低,因此我们可以考虑建索引。有两种选择,建 <first_name> 或 <first_name, last_name>,看下两个索引的选择性:
195+
如果频繁按名字搜索员工,这样显然效率很低,因此我们可以考虑建索引。有两种选择,建first_name或first_name,last_name,看下两个索引的选择性:
196196

197197
![索引选择性与前缀索引](/img/database-index/database-index-24.png)
198198

199-
显然<first_name>选择性太低,<first_name, last_name>选择性很好,但是first_name和last_name加起来长度为30,有没有兼顾长度和选择性的办法?可以考虑用first_name和last_name的前几个字符建立索引,例如<first_name, left(last_name, 3)>,看看其选择性:
199+
显然first_name选择性太低,first_name,last_name选择性很好,但是first_name和last_name加起来长度为30,有没有兼顾长度和选择性的办法?可以考虑用first_name和last_name的前几个字符建立索引,例如<first_name, left(last_name, 3)>,看看其选择性:
200200

201201
![索引选择性与前缀索引](/img/database-index/database-index-25.png)
202202

203203
选择性还不错,但离0.9313还是有点距离,那么把last_name前缀加到4:
204204

205205
![索引选择性与前缀索引](/img/database-index/database-index-26.png)
206206

207-
这时选择性已经很理想了,而这个索引的长度只有18,比<first_name, last_name>短了接近一半,我们把这个前缀索引建上:
207+
这时选择性已经很理想了,而这个索引的长度只有18,比first_name, last_name短了接近一半,我们把这个前缀索引建上:
208208

209209
![索引选择性与前缀索引](/img/database-index/database-index-27.png)
210210

0 commit comments

Comments
 (0)