数据库:zhcxkj-center-product
查询时间:56.8806
执行次数: 24
扫描行数:14824200
发送行数:338923
指纹SQL: select 'id' , 'customer_id' , 'sku' , 'platform_id' , 'risk_level' , 'platform_type' , 'update_time' , 'update_by' , 'create_by' , 'create_time' , 'is_deleted' , 'site_code' FROM ? where ( create_time < replace ( '?' , '?' , '?' ) AND ( create_time >= DATE_SUB ( replace ( '?' , '?' , '?' ) , INTERVAL ? HOUR ) ) ) ;
真实SQL:select 'id','customer_id','sku','platform_id','risk_level','platform_type','update_time','update_by','create_by','create_time','is_deleted','site_code' from rb_product_risk_level_platform_country where (create_time= DATE_SUB(replace('2025-08-19 11:00:19','%',' '), INTERVAL 1 HOUR)));
##无人工修改##
AISQL修改建议:# 优化后的SQL语句
SELECT 'id', 'customer_id', 'sku', 'platform_id', 'risk_level', 'platform_type',
'update_time', 'update_by', 'create_by', 'create_time', 'is_deleted', 'site_code'
FROM rb_product_risk_level_platform_country
WHERE create_time >= DATE_SUB('2025-08-19 11:00:19', INTERVAL 1 HOUR)
AND create_time < '2025-08-24 04:00:22';
优化说明:
1. 移除了不必要的'replace()'函数调用,直接使用日期字符串
2. 简化了日期条件表达式,提高可读性
3. 保持了相同的查询逻辑但更高效
4. 保留了所有原始查询字段
explain表:
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | SIMPLE | rb_product_risk_level_platform_country | None | ALL | None | None | None | None | 17669578 | 11.11 | Using where |
额外建议:
索引建议:
建议添加索引:ALTER TABLE rb_product_risk_level_platform_country ADD INDEX idx_create_time(create_time);
【rb_product_risk_level_platform_country】表 【create_time】字段,索引分析:
+--------------+--------------+---------------+---------------+
| TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
+==============+==============+===============+===============+
+--------------+--------------+---------------+---------------+
('2025-08-24>
