Created
April 10, 2019 08:55
-
-
Save ghotz/5b91815d1af4e498219747ee0ffc9985 to your computer and use it in GitHub Desktop.
Finds in Query Store forced plan not being forced and without an explanation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT I.start_time, I.end_time, P.query_id, p.plan_id | |
, (SELECT P2.plan_id | |
FROM sys.query_store_plan AS P2 | |
WHERE P.query_id = P2.query_id | |
AND P.plan_id <> P2.plan_id | |
AND P.last_force_failure_reason = 0 | |
) AS plan_id_different | |
FROM sys.query_store_runtime_stats_interval AS I | |
JOIN sys.query_store_runtime_stats AS S | |
ON I.runtime_stats_interval_id = S.runtime_stats_interval_id | |
JOIN sys.query_store_plan AS P | |
ON S.plan_id = P.plan_id | |
JOIN sys.query_store_query AS Q | |
ON P.query_id = Q.query_id | |
WHERE EXISTS ( | |
SELECT * | |
FROM sys.query_store_plan AS P2 | |
WHERE P.query_id = P2.query_id | |
AND P.plan_id <> P2.plan_id | |
AND P.last_force_failure_reason = 0 | |
) | |
AND P.is_forced_plan = 1 | |
ORDER BY | |
I.start_time | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment