数据库:zhcxkj-center-product
查询时间:55.8282
执行次数: 24
扫描行数:14843600
发送行数:358374
指纹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修改建议: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 BETWEEN DATE_SUB('2025-08-19 11:00:19', INTERVAL 1 HOUR) AND '2025-08-31 08:00:23'
优化说明:
1. 移除了不必要的replace函数调用,直接使用日期字符串
2. 使用BETWEEN替代两个单独的条件判断,使查询更简洁高效
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 | 17824658 | 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-31>
