[步骤]
select top 1000 * from irobotbox..RB_Log_SQLDuration(nolock) where BeginTime>'2024-12-05 09:20' and [IP]='0'
and SQLText like '%SUM(ol.ActivityMinusPrice)%'
order by
convert(nvarchar(max),SQLText) asc ,Duration desc
declare @CustomerID int=1,@OrderSourceID int=16332,@StartAddTime datetime='2024/12/2 8:36:03'
SELECT TOP 1 oi.OrderCode,MAX(oi.OrderSourceID) OrderSourceID,MAX(oi.ProductTotalPrice) ProductTotalPrice, SUM(ol.ActivityMinusPrice) AS TaxFee, oi.AddTime FROM dbo.RB_OrderInfo oi WITH(NOLOCK) --INNER JOIN dbo.RB_OrderSource os WITH(NOLOCK) ON os.ID = oi.OrderSourceID AND os.OrderSourceType = 1 --AND os.OrderSourceCountry = 'US'
INNER JOIN dbo.RB_OrderList ol WITH(NOLOCK) ON oi.CustomerID = ol.CustomerID AND oi.OrderCode = ol.OrderCode AND ol.ActivityMinusPrice <> 0
--INNER JOIN dbo.RB_Product_Fee pf WITH(NOLOCK) ON oi.OrderCode = pf.OrderCode AND pf.OperateType = 73 AND pf.OperateFee <> 0
WHERE oi.CustomerID = @CustomerID AND oi.OrderSourceID = @OrderSourceID AND oi.AddTime < @StartAddTime GROUP BY oi.OrderCode, oi.AddTime ORDER BY oi.AddTime DESC
[结果]
[期望]
排查性能问题 优化