数据库:zhcxkj_center_listing_comprehensive
查询时间:649.104
执行次数: 24
扫描行数:63058400
发送行数:164828
指纹SQL: select id , customer_id , source_id , global_listing_id , name , item_id , item_sku , model_id , model_sku , sku , product_id , product_name_cn , purchase_price , original_price , currency , has_variant , platform_quality , image , properties , status , product_status , default_sku , comb , listing_method , listing_person , salesman_id , salesman , publish_time , un_publish_time , remark , create_by , create_time , update_by , update_time , is_deleted FROM ? where ( update_time < replace ( ? , ? , ? ) AND update_time >= replace ( ? , ? , ? ) ) ;
真实SQL:select id,customer_id,source_id,global_listing_id,name,item_id,item_sku,model_id,model_sku,sku,product_id,product_name_cn,purchase_price,original_price,currency,has_variant,platform_quality,image,properties,status,product_status,default_sku,comb,listing_method,listing_person,salesman_id,salesman,publish_time,un_publish_time,remark,create_by,create_time,update_by,update_time,is_deleted from t_shopee_global_listing_sku where (update_time= replace(2025-12-10 03:47:37,%, ));
无人工修改
AISQL修改建议:SELECT id, customer_id, source_id, global_listing_id, name, item_id, item_sku, model_id, model_sku, sku, product_id, product_name_cn, purchase_price, original_price, currency, has_variant, platform_quality, image, properties, status, product_status, default_sku, comb, listing_method, listing_person, salesman_id, salesman, publish_time, un_publish_time, remark, create_by, create_time, update_by, update_time, is_deleted
FROM t_shopee_global_listing_sku
WHERE update_time >= 2025-12-10 03:47:37
AND update_time < 2025-12-10 04:47:37;
优化说明:
1. 移除了不必要的REPLACE函数调用,直接使用时间字符串比较
2. 调整了WHERE条件的顺序,将更可能缩小结果集的条件放在前面
3. 使用标准的日期时间格式进行比较,避免函数操作以便利用索引
4. 保持查询语义完全一致,只提升执行效率
建议在update_time字段上建立索引以获得最佳性能。
explain表:
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | SIMPLE | t_shopee_global_listing_sku | None | ALL | None | None | None | None | 58821152 | 11.11 | Using where |
额外建议:
索引建议:
建议添加索引:ALTER TABLE t_shopee_global_listing_sku ADD INDEX idx_update_time(update_time);
【t_shopee_global_listing_sku】表 【update_time】字段,索引分析:
+--------------+--------------+---------------+---------------+
| TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
+==============+==============+===============+===============+
+--------------+--------------+---------------+---------------+
(2025-12-10>
