中国网络水泥 发表于 2018-10-3 07:07:53

MySQL 优化之前缀索引

--查看选择率  select count(distinct(fileid))/count(*) AS Selectivity from t_file_info;
  select count(distinct left(fileid,32))/count(*) from t_file_info;
  (root@localhost) > select count(distinct(fileid))/count(*) from t_file_info;
  +----------------------------------+
  | count(distinct(fileid))/count(*) |
  +----------------------------------+
  |                           1.0000 |
  +----------------------------------+
  1 row in set (0.17 sec)
  (root@localhost) > select count(distinct left(fileid,32))/count(*) from t_file_info;
  +------------------------------------------+
  | count(distinct left(fileid,32))/count(*) |
  +------------------------------------------+
  |                                 0.9999 |
  +------------------------------------------+
  1和0.9999几乎可以等同,其实这里因为点特殊情况,正常应该都是1才对的。

页: [1]
查看完整版本: MySQL 优化之前缀索引