Skip to content

Commit e882bbd

Browse files
Merge pull request #714 from erikdarlingdata/fix/hi-exists-plan-apply
sp_QuickieStore: use EXISTS in final plan OUTER APPLY
2 parents 20a017f + f922d0e commit e882bbd

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

sp_QuickieStore/sp_QuickieStore.sql

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5606,10 +5606,15 @@ OUTER APPLY
56065606
qsp.last_execution_time DESC
56075607
),
56085608
qsp.query_plan
5609-
FROM #hi_id_staging_plans AS sp
5610-
JOIN ' + @database_name_quoted + N'.sys.query_store_plan AS qsp
5611-
ON qsp.plan_id = sp.plan_id
5612-
WHERE sp.query_hash = o.query_hash
5609+
FROM ' + @database_name_quoted + N'.sys.query_store_plan AS qsp
5610+
WHERE EXISTS
5611+
(
5612+
SELECT
5613+
1/0
5614+
FROM #hi_id_staging_plans AS sp
5615+
WHERE qsp.plan_id = sp.plan_id
5616+
AND sp.query_hash = o.query_hash
5617+
)
56135618
) AS qp0
56145619
WHERE qp0.n = 1
56155620
) AS qp

0 commit comments

Comments
 (0)