数据库:zhcxkj_center_strategy_comprehensive
查询时间:89.7529
执行次数: 86
扫描行数:1496920
发送行数:463.849
指纹SQL: SELECT id , retry_status , source_id FROM ? WHERE ( source_id = ? AND status = ? ) limit ? ;
真实SQL:SELECT id,retry_status,source_id FROM t_strategy_execute_queue_picture_ozon WHERE (source_id = 25665 AND status = 0) limit 1000;
王凯,人工修改过
AISQL修改建议: 优化后的SQL语句
SELECT id, retry_status, source_id
FROM t_strategy_execute_queue_picture_ozon
WHERE source_id = 25665 AND status = 0
LIMIT 1000;
优化说明:
1. 移除了不必要的括号,简化了查询结构
2. 为了进一步提升性能,建议在 source_id 和 status 字段上创建复合索引:
CREATE INDEX idx_source_status ON t_strategy_execute_queue_picture_ozon(source_id, status);
explain表:
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | SIMPLE | t_strategy_execute_queue_picture_ozon | None | ALL | None | None | None | None | 3004977 | 1 | Using where |
额外建议:
索引建议:
取出表 【t_strategy_execute_queue_picture_ozon】 where条件字段 【status】 100000 条记录,重复的数据有:【51918】 条。
建议添加索引:CREATE INDEX idx_source_status ON t_strategy_execute_queue_picture_ozon(source_id, status);
【t_strategy_execute_queue_picture_ozon】表 【source_id】字段,索引分析:
+--------------+--------------+---------------+---------------+
| TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
+==============+==============+===============+===============+
+--------------+--------------+---------------+---------------+
已解决