数据库:zhcxkj_center_strategy_comprehensive
查询时间:10.9493
执行次数: 34
扫描行数:68265.4
发送行数:877.5
指纹SQL: SELECT id , retry_status , source_id , country_code FROM ? WHERE ( source_id = ? AND status = ? ) limit ? ;
真实SQL:SELECT id,retry_status,source_id,country_code FROM t_strategy_execute_queue_edit_ozon WHERE (source_id = 25655 AND status = 0) limit 1000;
无人工修改
AISQL修改建议: 优化后的SQL语句
SELECT id, retry_status, source_id, country_code
FROM t_strategy_execute_queue_edit_ozon
WHERE source_id = 25655 AND status = 0
LIMIT 1000;
优化建议
1. 去除了不必要的括号,虽然对性能影响很小,但使SQL更简洁
2. 最重要的是,建议在表上创建复合索引:(source_id, status)
3. 如果经常查询这4个字段,可以考虑创建一个覆盖索引:(source_id, status, id, retry_status, country_code)
创建索引的SQL(如果需要)
ALTER TABLE t_strategy_execute_queue_edit_ozon ADD INDEX idx_source_status (source_id, status);
-- 或者创建覆盖索引
ALTER TABLE t_strategy_execute_queue_edit_ozon ADD INDEX idx_covering (source_id, status, id, retry_status, country_code);
explain表:
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | SIMPLE | t_strategy_execute_queue_edit_ozon | None | ref | idx_source_id,idx_status | idx_status | 5 | const | 75 | 0.94 | Using where |
额外建议:
索引建议:

