Skip to content

Commit 31b7c21

Browse files
Merge pull request #750 from erikdarlingdata/dev
Merge dev to main: sp_QuickieCache v1.4
2 parents 76a2f0f + 6f20926 commit 31b7c21

1 file changed

Lines changed: 86 additions & 27 deletions

File tree

sp_QuickieCache/sp_QuickieCache.sql

Lines changed: 86 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,50 @@
1-
SET ANSI_NULLS ON;
1+
SET ANSI_WARNINGS ON;
2+
SET ARITHABORT ON;
3+
SET CONCAT_NULL_YIELDS_NULL ON;
24
SET QUOTED_IDENTIFIER ON;
5+
SET NUMERIC_ROUNDABORT OFF;
6+
SET IMPLICIT_TRANSACTIONS OFF;
7+
SET STATISTICS TIME, IO OFF;
38
GO
49

10+
/*
11+
██████╗ ██╗ ██╗██╗ ██████╗██╗ ██╗██╗███████╗ ██████╗ █████╗ ██████╗██╗ ██╗███████╗
12+
██╔═══██╗██║ ██║██║██╔════╝██║ ██╔╝██║██╔════╝██╔════╝██╔══██╗██╔════╝██║ ██║██╔════╝
13+
██║ ██║██║ ██║██║██║ █████╔╝ ██║█████╗ ██║ ███████║██║ ███████║█████╗
14+
██║▄▄ ██║██║ ██║██║██║ ██╔═██╗ ██║██╔══╝ ██║ ██╔══██║██║ ██╔══██║██╔══╝
15+
╚██████╔╝╚██████╔╝██║╚██████╗██║ ██╗██║███████╗╚██████╗██║ ██║╚██████╗██║ ██║███████╗
16+
╚══▀▀═╝ ╚═════╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝╚══════╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝
17+
18+
sp_QuickieCache: The plan cache companion to sp_QuickieStore.
19+
20+
Copyright 2026 Darling Data, LLC
21+
https://www.erikdarling.com/
22+
23+
For usage and licensing details, run:
24+
EXECUTE sp_QuickieCache
25+
@help = 1;
26+
27+
For working through errors:
28+
EXECUTE sp_QuickieCache
29+
@debug = 1;
30+
31+
For support, head over to GitHub:
32+
https://code.erikdarling.com
33+
34+
Uses the Pareto principle to find the vital few queries consuming
35+
disproportionate resources across statements, procedures, functions,
36+
and triggers. Scores across 7 dimensions using PERCENT_RANK and
37+
surfaces queries with impact_score >= @impact_threshold.
38+
39+
Data sources:
40+
* sys.dm_exec_query_stats (statements)
41+
* sys.dm_exec_procedure_stats (stored procedures)
42+
* sys.dm_exec_function_stats (scalar/table-valued functions)
43+
* sys.dm_exec_trigger_stats (triggers)
44+
45+
Requires SQL Server 2016 SP1+ for memory grant and spill columns.
46+
*/
47+
548
IF OBJECT_ID(N'dbo.sp_QuickieCache', N'P') IS NULL
649
BEGIN
750
EXECUTE(N'CREATE PROCEDURE dbo.sp_QuickieCache AS RETURN 138;');
@@ -20,39 +63,19 @@ ALTER PROCEDURE
2063
@ignore_system_databases bit = 1, /*exclude master, model, msdb, tempdb*/
2164
@impact_threshold decimal(3, 2) = 0.50, /*minimum impact_score to surface (0.00-1.00)*/
2265
@debug bit = 0, /*print diagnostics*/
23-
@help bit = 0 /*display parameter help*/
66+
@help bit = 0, /*display parameter help*/
67+
@version varchar(30) = NULL OUTPUT, /*OUTPUT; for support*/
68+
@version_date datetime = NULL OUTPUT /*OUTPUT; for support*/
2469
)
2570
WITH RECOMPILE
2671
AS
2772
BEGIN
2873
SET NOCOUNT ON;
2974
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
3075

31-
/*
32-
██████╗ ██╗ █████╗ ███╗ ██╗ ██████╗ █████╗ ██████╗██╗ ██╗███████╗
33-
██╔══██╗██║ ██╔══██╗████╗ ██║ ██╔════╝██╔══██╗██╔════╝██║ ██║██╔════╝
34-
██████╔╝██║ ███████║██╔██╗ ██║ ██║ ███████║██║ ███████║█████╗
35-
██╔═══╝ ██║ ██╔══██║██║╚██╗██║ ██║ ██╔══██║██║ ██╔══██║██╔══╝
36-
██║ ███████╗██║ ██║██║ ╚████║ ╚██████╗██║ ██║╚██████╗██║ ██║███████╗
37-
╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝
38-
39-
sp_QuickieCache: The plan cache companion to sp_QuickieStore.
40-
41-
Copyright 2026 Erik Darling Data, LLC
42-
43-
Uses the Pareto principle to find the vital few queries consuming
44-
disproportionate resources across statements, procedures, functions,
45-
and triggers. Scores across 7 dimensions using PERCENT_RANK and
46-
surfaces queries with impact_score >= @impact_threshold.
47-
48-
Data sources:
49-
sys.dm_exec_query_stats (statements)
50-
sys.dm_exec_procedure_stats (stored procedures)
51-
sys.dm_exec_function_stats (scalar/table-valued functions)
52-
sys.dm_exec_trigger_stats (triggers)
53-
54-
Requires SQL Server 2016 SP1+ for memory grant and spill columns.
55-
*/
76+
SELECT
77+
@version = '1.4',
78+
@version_date = '20260401';
5679

5780
/*
5881
╔══════════════════════════════════════════════════╗
@@ -88,6 +111,10 @@ BEGIN
88111
THEN N'Print diagnostic information. Default: 0.'
89112
WHEN N'@help'
90113
THEN N'You are here. Default: 0.'
114+
WHEN N'@version'
115+
THEN N'OUTPUT; for support.'
116+
WHEN N'@version_date'
117+
THEN N'OUTPUT; for support.'
91118
ELSE N''
92119
END
93120
FROM sys.all_parameters AS ap
@@ -104,6 +131,38 @@ BEGIN
104131
high_signal = N'Dimensions where query ranks >= 80th percentile',
105132
output = N'Queries with impact_score >= @impact_threshold, plus workload profile summary';
106133

134+
/*
135+
License to F5
136+
*/
137+
SELECT
138+
mit_license_yo =
139+
'i am MIT licensed, so like, do whatever'
140+
UNION ALL
141+
142+
SELECT
143+
mit_license_yo =
144+
'see printed messages for full license';
145+
146+
RAISERROR('
147+
MIT License
148+
149+
Copyright 2026 Darling Data, LLC
150+
151+
https://www.erikdarling.com/
152+
153+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
154+
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute,
155+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
156+
following conditions:
157+
158+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
159+
160+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
161+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
162+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
163+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
164+
', 0, 1) WITH NOWAIT;
165+
107166
RETURN;
108167
END;
109168

0 commit comments

Comments
 (0)