小编far*_*ess的帖子

用于 concat select 的 MySQL 索引

对于以下查询

SELECT MAX(CONCAT(date, ' ', last_entry)) AS LAST_LOG
    FROM entry_log
    WHERE TRIM(LEADING 0 FROM card_no)='2948'
Run Code Online (Sandbox Code Playgroud)

我已经索引了

date
card_no
date,last_entry
date,last_entry,card_no
Run Code Online (Sandbox Code Playgroud)

我的解释显示

id  select_type     table       type    possible_keys   key             key_len     ref     rows    Extra   
1   SIMPLE          entry_log   index   NULL            date_last_card  158         NULL    103766  Using where; Using index
Run Code Online (Sandbox Code Playgroud)

我的解释扩展节目

id  select_type     table           type    possible_keys   key             key_len     ref     rows    filtered    Extra   
1     SIMPLE        entry_log       index   NULL            date_last_card  158         NULL    103766  100.00      Using where; Using index
Run Code Online (Sandbox Code Playgroud)

我想知道我可以删除/使用哪个索引,我的路径是否正确,我应该如何提高上述查询的执行时间?

CREATE TABLE `entry_log` (
 `id` int(11) NOT NULL AUTO_INCREMENT, …
Run Code Online (Sandbox Code Playgroud)

mysql index optimization index-tuning explain

5
推荐指数
1
解决办法
4223
查看次数

标签 统计

explain ×1

index ×1

index-tuning ×1

mysql ×1

optimization ×1