Skip to content

Commit 3249e99

Browse files
authored
Merge pull request #3854 from BrentOzarULTD/copilot/fix-sp-blitzcache-null-query-plan
sp_BlitzCache: Skip AI calls for null query plans, allow @ai=2 prompts without plans
2 parents 24012b2 + b71cb3a commit 3249e99

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

sp_BlitzCache.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5340,7 +5340,7 @@ XML Execution Plan:
53405340
Thank you.'
53415341
FROM ##BlitzCacheProcs p
53425342
WHERE p.SPID = @@SPID
5343-
AND p.QueryPlan IS NOT NULL
5343+
AND (@AI = 2 OR p.QueryPlan IS NOT NULL) /* For @AI = 1, skip null plans (no value calling AI without a plan); for @AI = 2, build prompts even when plan is null */
53445344
AND NOT (p.QueryType LIKE 'Procedure or Function:%' /* This and the below exists query makes sure that we don't get advice for parent procs, only their statements, if the statements are in our result set. */
53455345
AND EXISTS
53465346
(
@@ -5530,7 +5530,7 @@ Thank you.'
55305530
UPDATE ##BlitzCacheProcs
55315531
SET ai_advice = N'AI prompt generated but not sent (running with @AI = 2). Review the ai_prompt column for the prompt that would be sent.'
55325532
WHERE SPID = @@SPID
5533-
AND QueryPlan IS NOT NULL
5533+
AND ai_prompt IS NOT NULL
55345534
OPTION (RECOMPILE);
55355535
END;
55365536
END;

0 commit comments

Comments
 (0)