Skip to content

Commit ac629b3

Browse files
committed
选择合适的索引列
1 parent c5bddd3 commit ac629b3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mysql索引优化/如何选择合适的列简历索引

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ select count(distinct customer_id), count(distinct staff_id) from payment;<br>
77

88
离散度,我的理解就是唯一性了,比如主键,绝对是离散度最大的,而一些用来标识状态标识的列,基本只有几个可选项,离散度就很小
99

10-
10+
离散程度的大小的判定方法:
11+
计算出数据库中记录不重复数量
12+
select count(distinct row1),count(distinct row2) from table;
13+
count()值大的就离散度高。

0 commit comments

Comments
 (0)