mysql变长大字段加索引

仁义礼智信的 / 2023-08-22 / 原文

通过下面sql查看左前匹配区分度

区分度大于90%,即可选length作为该字段的索引长度

select count(distinct(left(table_field,length)))/count(*)from table_name;

一般区分度大于33%就算比较高效的索引