数据库:zhcxkj_center_risk
查询时间:201.316
执行次数: 231
扫描行数:41322600
发送行数:1282.2
指纹SQL: select 'id' , 'flyback_task_id' , 'flyback_result_id' , 'product_id' , 'sku' , 'audit_status' , 'law_firm_agent_status' , 'similarity' , 'url' , 'name' , 'patent_library_id' , 'source_type' , 'area_id' , 'create_by' , 'create_time' , 'update_by' , 'update_time' , 'is_deleted' FROM ? where ( update_time >= replace ( '?' , '?' , '?' ) ) ;
真实SQL:select 'id','flyback_task_id','flyback_result_id','product_id','sku','audit_status','law_firm_agent_status','similarity','url','name','patent_library_id','source_type','area_id','create_by','create_time','update_by','update_time','is_deleted' from t_patent_flyback_result_detail where (update_time>= replace('2025-08-24 07:50:11','%',' '));
##无人工修改##
AISQL修改建议:# 优化后的SQL语句
SELECT 'id', 'flyback_task_id', 'flyback_result_id', 'product_id', 'sku',
'audit_status', 'law_firm_agent_status', 'similarity', 'url', 'name',
'patent_library_id', 'source_type', 'area_id', 'create_by', 'create_time',
'update_by', 'update_time', 'is_deleted'
FROM t_patent_flyback_result_detail
WHERE update_time >= STR_TO_DATE('2025-08-24 07:50:11', '%Y-%m-%d %H:%i:%s');
优化说明:
1. 使用STR_TO_DATE函数替代REPLACE函数处理日期字符串,这是更规范的方式
2. 移除了不必要的括号,使SQL更简洁
3. 格式化列名排列,提高可读性
如果'update_time'字段没有索引,建议添加索引以进一步提升性能:
ALTER TABLE t_patent_flyback_result_detail ADD INDEX idx_update_time (update_time);
explain表:
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | SIMPLE | t_patent_flyback_result_detail | None | ALL | None | None | None | None | 40824748 | 33.33 | Using where |
额外建议:
索引建议:
建议添加索引:ALTER TABLE t_patent_flyback_result_detail ADD INDEX idx_update_time(update_time);
【t_patent_flyback_result_detail】表 【update_time】字段,索引分析:
+--------------+--------------+---------------+---------------+
| TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
+==============+==============+===============+===============+
+--------------+--------------+---------------+---------------+