You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d43cc4f
Browse filesBrowse the repository at this point in the historyBrowse files
/* If we can't read it (permissions, offline, etc), just skip. */
5195
+
ENDCATCH;
5196
+
5197
+
FETCHNEXTFROM ai_db_cursor INTO @ai_db;
5198
+
END;
5199
+
5200
+
CLOSE ai_db_cursor;
5201
+
DEALLOCATE ai_db_cursor;
5202
+
5203
+
/* Update ai_prompt column with query metrics for rows that have query plans */
5204
+
UPDATE p
5205
+
SET ai_prompt =COALESCE(ai_prompt, N'') +N'---'+ @nl +N'This database has an extended property named CONSTITUTION.md that provides additional guidance for AI analysis. Here is the content of that property:'+ @nl +N'---'+ @nl +c.Constitution+ @nl +N'---'+ @nl
5206
+
FROM ##BlitzCacheProcs p
5207
+
INNER JOIN #ai_constitution c ONp.DatabaseName=c.DatabaseName
5208
+
WHEREp.SPID=@@SPID
5209
+
ANDc.ConstitutionISNOTNULL
5210
+
ANDLEN(c.Constitution) >0;
5211
+
5212
+
5122
5213
/* Update ai_prompt column with query metrics for rows that have query plans */
5123
5214
UPDATE p
5124
-
SET ai_prompt = N'Here are the performance metrics we are seeing in production, as measured by the plan cache:
5215
+
SET ai_prompt =COALESCE(ai_prompt, N'') +N'Here are the performance metrics we are seeing in production, as measured by the plan cache:
5125
5216
5126
-
Database: '+ISNULL(DatabaseName, N'Unknown') + N'
5217
+
Database: '+ISNULL(p.DatabaseName, N'Unknown') + N'
5127
5218
Query Type: '+ISNULL(QueryType, N'Unknown') + N'
5128
5219
Execution Count: '+ISNULL(CAST(ExecutionCount ASNVARCHAR(30)), N'N/A') + N'
5129
5220
Executions Per Minute: '+ISNULL(CAST(ExecutionsPerMinute ASNVARCHAR(30)), N'N/A') + N'
@@ -5188,6 +5279,7 @@ XML Execution Plan:
5188
5279
5189
5280
Thank you.'
5190
5281
FROM ##BlitzCacheProcs p
5282
+
LEFT JOIN #ai_constitution c ONp.DatabaseName=c.DatabaseName
5191
5283
WHEREp.SPID=@@SPID
5192
5284
ANDp.QueryPlanISNOTNULL
5193
5285
ANDNOT (p.QueryTypeLIKE'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. */
0 commit comments