我有表Customer_AJ(客戶varchar,項目編號,購買日期時間),我有兩個表與它成功和失敗,我希望所有沒有成功的失敗在該客戶的未來30分鐘內。Azure SQL數據庫左連接循環與150萬條記錄
我試了一下BYS使用不存在的,但它是在hashMatch得到循環(正如我在queryplan看到它,蔭連接查詢和執行計劃的屏幕截圖..
with Failure as (
select * from [dbo].[Customer_AJ] where item in (20, 34, 35, 36, 37, 47, 53, 54)
) ,
success as (
select * from Customer_AJ where Item in (1, 3, 40, 42, 43, 5)
) ,
final as (
select f.customer, f.item,f.purchase from Failure f left outer join success s
on f.customer = s.customer and DATEDIFF(minute , f.purchase , s.purchase) between 0 and 30
where s.customer is NULL
)
select * from final
Here is the Query Execution plan for it
而不是實時查詢統計的截圖,通過實際執行計劃XML到https://www.brentozar.com/pastetheplan/並添加鏈接到您的問題。 –