数据库:zhcxkj_center_strategy_comprehensive
查询时间:31.5849
执行次数: 40
扫描行数:923209
发送行数:1000
指纹SQL: SELECT id , retry_status , source_id , country_code FROM ? WHERE ( id > ? AND source_id = ? AND status = ? AND create_time <= ? ) limit ? ;
真实SQL:SELECT id,retry_status,source_id,country_code FROM t_strategy_execute_queue_offline_fruugo WHERE (id > 726341 AND source_id = 27739 AND status = 5 AND create_time <= 2025-11-01 00:00:00) limit 1000;
无人工修改
AISQL修改建议:CREATE INDEX idx_optimized ON t_strategy_execute_queue_offline_fruugo (source_id, status, create_time, id);
explain表:
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | SIMPLE | t_strategy_execute_queue_offline_fruugo | None | range | PRIMARY,idx_source_id,idx_source_id_status,idx_create_time_status | PRIMARY | 8 | None | 3961123 | 0.57 | Using where |
额外建议:
索引建议:
取出表 【t_strategy_execute_queue_offline_fruugo】 where条件字段 【source_id】 100000 条记录,重复的数据有:【96730】 条,没有必要为该字段创建索引。
取出表 【t_strategy_execute_queue_offline_fruugo】 where条件字段 【status】 100000 条记录,重复的数据有:【80375】 条,没有必要为该字段创建索引。
建议添加索引:ALTER TABLE t_strategy_execute_queue_offline_fruugo ADD INDEX idx_id_create_time(id,create_time);
【t_strategy_execute_queue_offline_fruugo】表 【id,create_time】字段,索引分析:
+--------------------------------+------------------------+---------------+---------------+
| TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
+================================+========================+===============+===============+
| t_strategy_execute_queue_offli | idx_create_time_status | create_time | 498223 |
| ne_fruugo | | | |
+--------------------------------+------------------------+---------------+---------------+
| t_strategy_execute_queue_offli | PRIMARY | id | 7746905 |
| ne_fruugo | | | |
+--------------------------------+------------------------+---------------+---------------+
已解决