数据库:zhcxkj_center_listing_comprehensive
查询时间:164.786
执行次数: 289
扫描行数:7085570
发送行数:294.228
指纹SQL: SELECT Id AS Id , ? AS CustomerId , Source_Id AS OrderSourceIdByLong , Site_Id AS SiteId , Sku AS Sku , Source_Sku AS SellerSku , Pf_Global_Listing_Id AS ProductId , Pf_Listing_Id AS SiteProductId , sale_price AS Price , Stock AS Quantity , Category_Id AS CategoryId , Publish_Time AS PublishTime , Update_Time AS UpdateTime , pf_online_time AS DateCreated , logistic_type AS LogisticType , Title AS SiteTitle , CAST ( Status AS CHAR ) AS Status , original_price AS OriginalPrice , sub_status AS SubStatus , ? AS IsSyncSuccess , ? AS SyncType FROM T_Listing_Mercadolibre WHERE ( ( ( Source_Id = ? ) AND ( Update_Time >= timestamp ( ? ) ) ) AND ( Update_Time <= timestamp ( ? ) ) ) ORDER BY Id LIMIT ? , ? ;
真实SQL:SELECT Id AS Id , 1 AS CustomerId , Source_Id AS OrderSourceIdByLong , Site_Id AS SiteId , Sku AS Sku , Source_Sku AS SellerSku , Pf_Global_Listing_Id AS ProductId , Pf_Listing_Id AS SiteProductId , sale_price AS Price , Stock AS Quantity , Category_Id AS CategoryId , Publish_Time AS PublishTime , Update_Time AS UpdateTime , pf_online_time AS DateCreated , logistic_type AS LogisticType , Title AS SiteTitle , CAST(Status AS CHAR) AS Status , original_price AS OriginalPrice , sub_status AS SubStatus , 1 AS IsSyncSuccess , 2 AS SyncType FROM T_Listing_Mercadolibre WHERE ((( Source_Id =28058) AND ( Update_Time >= timestamp(2025-08-28 01:55:00) )) AND ( Update_Time <= timestamp(2025-08-28 04:00:00) )) ORDER BY Id LIMIT 0,300;
袁慧斌,人工修改过
AISQL修改建议:以下是优化后的SQL语句:
SELECT Id AS Id,
1 AS CustomerId,
Source_Id AS OrderSourceIdByLong,
Site_Id AS SiteId,
Sku AS Sku,
Source_Sku AS SellerSku,
Pf_Global_Listing_Id AS ProductId,
Pf_Listing_Id AS SiteProductId,
sale_price AS Price,
Stock AS Quantity,
Category_Id AS CategoryId,
Publish_Time AS PublishTime,
Update_Time AS UpdateTime,
pf_online_time AS DateCreated,
logistic_type AS LogisticType,
Title AS SiteTitle,
CAST(Status AS CHAR) AS Status,
original_price AS OriginalPrice,
sub_status AS SubStatus,
1 AS IsSyncSuccess,
2 AS SyncType
FROM T_Listing_Mercadolibre
WHERE Source_Id = 28058
AND Update_Time BETWEEN 2025-08-28 01:55:00 AND 2025-08-28 04:00:00
ORDER BY Id
LIMIT 300;
优化说明:
1. 简化了WHERE条件,使用BETWEEN替代了多个时间比较
2. 移除了不必要的括号嵌套
3. 简化了LIMIT语法(从LIMIT 0,300改为直接LIMIT 300)
4. 移除了timestamp函数调用,使用直接的日期字符串
5. 保持相同的查询逻辑,但使语句更简洁高效
explain表:
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | SIMPLE | T_Listing_Mercadolibre | None | range | uk_source_id_country_code_pf_listing_logistic_type_platform_type,idx_update_time,idx_source_id_update_time,idx_source_site_status,idx_listing_mercadolibre_optim | idx_source_id_update_time | 14 | None | 304 | 100 | Using index condition; Using filesort |
额外建议:查看是否缺少索引
索引建议:
