数据库:zhcxkj_center_crm
查询时间:13.548
扫描行数:9778.96
发送行数:4686.12
指纹SQL: select * FROM ? where create_time >= ? and platform = ? ;
真实SQL:select * from t_crm_message_aliexpress where create_time >= 2025-08-05 and platform = 57;
无人工修改
AISQL修改建议: 优化后的SQL语句
SELECT id, /* 这里列出你实际需要的字段而不是使用* */
FROM t_crm_message_aliexpress
WHERE create_time >= 2025-08-05
AND platform = 57
ORDER BY create_time
LIMIT 1000; /* 根据实际情况调整限制数量 */
-- 建议在create_time和platform字段上创建复合索引
-- CREATE INDEX idx_msg_aliexpress_time_platform ON t_crm_message_aliexpress(create_time, platform);
优化说明:
1. 避免使用SELECT *,只查询需要的字段
2. 添加ORDER BY子句确保结果有序
3. 添加LIMIT限制返回数据量
4. 建议创建复合索引提高查询效率
explain表:
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | SIMPLE | t_crm_message_aliexpress | None | range | idx_create_time,idx_order_source | idx_create_time | 9 | None | 14900 | 100 | Using index condition |
额外建议:
索引建议:
取出表 【t_crm_message_aliexpress】 where条件表达式 【platform = 57】 100000 条记录,重复的数据有:【100000】 条,没有必要为该字段创建索引。
→ 【t_crm_message_aliexpress】表 【create_time】字段,索引已经存在,无需添加任何索引。
【t_crm_message_aliexpress】表 【create_time】字段,索引分析:
+--------------------------+--------------------------------+---------------+---------------+
| TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
+==========================+================================+===============+===============+
| t_crm_message_aliexpress | idx_create_time | create_time | 830661 |
+--------------------------+--------------------------------+---------------+---------------+
| t_crm_message_aliexpress | t_crm_message_aliexpress_messa | create_time | 1104905 |
| | ge_type_IDX | | |
+--------------------------+--------------------------------+---------------+---------------+