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
Copy file name to clipboardExpand all lines: sp_BlitzCache.sql
+61-49Lines changed: 61 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -354,7 +354,7 @@ IF @Help = 1
354
354
UNION ALL
355
355
SELECTN'@SortOrder',
356
356
N'VARCHAR(10)',
357
-
N'Data processing and display order. @SortOrder will still be used, even when preparing output for a table or for excel. Possible values are: "CPU", "Reads", "Writes", "Duration", "Executions", "Recent Compilations", "Memory Grant", "Unused Grant", "Spills", "Query Hash", "Duplicates". Additionally, the word "Average" or "Avg" can be used to sort on averages rather than total. "Executions per minute" and "Executions / minute" can be used to sort by execution per minute. For the truly lazy, "xpm" can also be used. Note that when you use all or all avg, the only parameters you can use are @Top and @DatabaseName. All others will be ignored.'
357
+
N'Data processing and display order. @SortOrder will still be used, even when preparing output for a table or for excel. Possible values are: "CPU", "Reads", "Writes", "Duration", "Executions", "Recent Compilations", "Memory Grant", "Unused Grant", "Spills", "Query Hash", "Duplicate". Additionally, the word "Average" or "Avg" can be used to sort on averages rather than total. "Executions per minute" and "Executions / minute" can be used to sort by execution per minute. For the truly lazy, "xpm" can also be used. Note that when you use all or all avg, the only parameters you can use are @Top and @DatabaseName. All others will be ignored.'
358
358
359
359
UNION ALL
360
360
SELECTN'@UseTriggersAnyway',
@@ -776,12 +776,30 @@ END;
776
776
/* Lets get @SortOrder set to lower case here for comparisons later */
777
777
SET @SortOrder =LOWER(@SortOrder);
778
778
779
+
/* Set @Top based on sort */
780
+
IF (
781
+
@Top ISNULL
782
+
AND @SortOrder IN ( 'all', 'all sort' )
783
+
)
784
+
BEGIN
785
+
SET @Top =5;
786
+
END;
787
+
788
+
IF (
789
+
@Top ISNULL
790
+
AND @SortOrder NOTIN ( 'all', 'all sort' )
791
+
)
792
+
BEGIN
793
+
SET @Top =10;
794
+
END;
795
+
796
+
779
797
/* If they want to sort by query hash, populate the @OnlyQueryHashes list for them */
RAISERROR(N'Invalid sort order chosen, reverting to cpu', 16, 1) WITHNOWAIT;
964
964
SET @SortOrder ='cpu';
@@ -1801,6 +1801,10 @@ FROM (SELECT TOP (@Top) x.*, xpa.*,
1801
1801
CROSS APPLY (SELECT * FROM sys.dm_exec_plan_attributes(x.plan_handle) AS ixpa
1802
1802
WHERE ixpa.attribute = ''dbid'') AS xpa '+ @nl ;
1803
1803
1804
+
IF @SortOrder ='duplicate'/* Issue #3345 */
1805
+
BEGIN
1806
+
SET @body +=N' INNER JOIN #duplicate_query_filter AS dqf ON x.sql_handle = dqf.sql_handle AND x.plan_handle = dqf.plan_handle AND x.creation_time = dqf.duplicate_creation_time '+ @nl ;
0 commit comments