[步骤]
CPU top 5 基本全占

T_175589220.[OrderSourceCountry] AS index_676492909_c25581fe,
T_175589220.[付款时间] AS index_628532388_590c9510,
T_175589220.[发货方式] AS index_674782828_08492088,
T_175589220.[订单数] AS index_35039197_fbb493d0,
T_175589220.[账号类型] AS index_1098134977_c65d9276,
T_175589220.[销售额] AS index_37371439_9ae44464,
T_175589220.[销量] AS index_1219791_44e7ebb4
FROM
(
SELECT
CONVERT(VARCHAR(10),b.PayTime,111) '付款时间',
case when d.UserFullPathName like '%亚马逊平台运营中心%' then '公共账号' ELSE '独立账号' end '账号类型',
c.OrderSourceCountry,
case when e.WareHouseType=3 then 'FBA' else 'FBM' end '发货方式',
SUM(a.ProductNum+a.ProductNumUpdate) '销量',
count(DISTINCT a.OrderCode) '订单数',
SUM(A.ProductPrice*B.ExchangeRMB*(a.ProductNum+a.ProductNumUpdate)) '销售额'
FROM RB_OrderList a (nolock)
LEFT JOIN RB_OrderInfo b (nolock) on a.CustomerID=b.CustomerID and a.OrderCode=b.OrderCode
LEFT JOIN RB_OrderSource c (nolock) on b.CustomerID=c.CustomerID and b.OrderSourceID=c.ID
LEFT JOIN RB_Admin d (nolock) on c.CustomerID=d.CustomerID and c.SaleAdminID=d.ID
LEFT JOIN RB_WareHouse e (nolock) on b.CustomerID=e.CustomerID and b.WareHouseID=e.ID
WHERE a.CustomerID = 1 AND b.OrderStatus != 2 AND c.OrderSourceType = 1
AND a.BusinessTeamName NOT LIKE '%品牌%' AND COALESCE(a.OrderCode,'') != '' AND b.IsPay = 1 AND b.IsStockOrder = 0
AND b.PayTime > '2024-01-01'
GROUP BY CONVERT(VARCHAR(10),b.PayTime,111),
case when d.UserFullPathName like '%亚马逊平台运营中心%' then '公共账号' ELSE '独立账号' end,
case when e.WareHouseType=3 then 'FBA' else 'FBM' end,
c.OrderSourceCountry
) AS T_175589220
[结果]
[期望]
优化SQL 提升性能,缓减读库压力