1. 问题描述
慢sql查询,经常出现在慢sql 列表,3000多秒执行
2.问题分析
慢sql查询RB_Ebay_Listing_AutoSupplement_V2 秒表有8000万数据,查询了 * 所有列, 测试去掉SELECT alias.*, 查询11秒出结果
3.解决方案
去掉SELECT alias.*, 所有字段查找,根据业务查询需要的具体字段
4.ramark:
SELECT alias.*,
b.ItemID,
c.SKU,
c.OrderSourceSKU,
c.Quantity,
c.ProductType AS MainProductType,
c.IsVariation AS IsProductVariation,
Isnull(p.ProductState, 0) AS ProductState,
B.Duration
FROM RB_Ebay_Listing_AutoSupplement_V2 alias WITH(nolock)
INNER JOIN RB_Ebay_Listing_Basic_V2 b WITH(nolock)
ON alias.CustomerID = b.CustomerID
AND alias.ListingBasicID = b.ListingBasicID
AND alias.OrderSourceID = b.OrderSourceID
INNER JOIN RB_Ebay_Listing_Product_V2 c WITH(nolock)
ON alias.CustomerID = c.CustomerID
AND alias.ListingBasicID = c.ListingBasicID
AND alias.ListingProductID = c.ListingProductID
AND alias.OrderSourceID = c.OrderSourceID
LEFT JOIN RB_Product p WITH(nolock)
ON c.CustomerID = p.CustomerID
AND c.SKU = p.SKU
WHERE b.OnlineState = 1
AND b.ListingType = 8
AND alias.CustomerID = 1
AND alias.OrderSourceID = 6864
AND alias.EnableAutoSupplement = 1
AND ( alias.IsInventoryCheck IS NULL
OR alias.IsInventoryCheck = 0 )

3.解决方案
去掉SELECT alias.*, 所有字段查找,根据业务查询需要的具体字段