问题SQL:
explain SELECT
*
FROM
t_config
WHERE
id IN (
SELECT
max( id )
FROM
t_config
WHERE
creator = '12344354@qq.com'
AND camp_id IN ( SELECT plan_id FROM t_task WHERE creator_id = '12344354@xdf.cn' AND source_type = 2 AND STATUS = 1 )
GROUP BY
integral_id
)
执行计划:
执行计划.png执行计划中,可以看到并没有走索引。问题是子查询中in( select max(id))
此时在索引列上使用了函数导致没走索引。
网友评论