@@ -24,13 +24,21 @@ https://github.com/erikdarlingdata/DarlingData
24
24
EXEC dbo .sp_QuickieStore
25
25
@help = 1 ;
26
26
27
+ /* The default is finding the top 10 sorted by CPU in the last seven days.*/
28
+ EXEC dbo .sp_QuickieStore
29
+ @database_name = ' StackOverflow2013' ;
27
30
28
31
/* Find top 10 sorted by memory*/
29
32
EXEC dbo .sp_QuickieStore
30
33
@database_name = ' StackOverflow2013' ,
31
34
@sort_order = ' memory' ,
32
- @top = 10 ;
35
+ @top = 10 ;
33
36
37
+ /* Find top 10 in each user database sorted by cpu*/
38
+ EXEC dbo .sp_QuickieStore
39
+ @get_all_databases = 1 ,
40
+ @sort_order = ' cpu' ,
41
+ @top = 10 ;
34
42
35
43
/* Search for specific query_ids*/
36
44
EXEC dbo .sp_QuickieStore
@@ -72,6 +80,13 @@ EXEC dbo.sp_QuickieStore
72
80
@start_date = ' 20210320' ,
73
81
@end_date = ' 20210321' ;
74
82
83
+ /* Filter out weekends and anything outside of your choice of hours.*/
84
+ EXEC dbo .sp_QuickieStore
85
+ @database_name = ' StackOverflow2013' ,
86
+ @workdays = 1 ,
87
+ @work_start = ' 8am' ,
88
+ @work_end = ' 6pm'
89
+
75
90
76
91
/* Search for queries with a minimum execution count*/
77
92
EXEC dbo .sp_QuickieStore
@@ -87,6 +102,26 @@ EXEC dbo.sp_QuickieStore
87
102
@duration_ms = 10000 ;
88
103
89
104
105
+ /* Use wait filter to search for queries responsible for high waits*/
106
+ EXEC dbo .sp_QuickieStore
107
+ @database_name = ' StackOverflow2013' ,
108
+ @wait_filter = ' memory' ,
109
+ @sort_order = ' memory' ;
110
+
111
+ /* We also support using wait types as a sort order, see the documentation for the full list.
112
+ The wait-related sort orders are special because we add an extra column for the duration of the wait type you are asking for.
113
+ It's all the way over on the right.
114
+ */
115
+ EXEC dbo .sp_QuickieStore
116
+ @database_name = ' StackOverflow2013' ,
117
+ @sort_order = ' memory waits' ;
118
+
119
+ /* You can also sort by total wait time across all waits. */
120
+ EXEC dbo .sp_QuickieStore
121
+ @database_name = ' StackOverflow2013' ,
122
+ @sort_order = ' total waits' ;
123
+
124
+
90
125
/* Search for queries with a specific execution type
91
126
When we do not provide this parameter, we grab all types.
92
127
This example grabs "aborted" queries, which are queries cancelled by the client.
@@ -120,13 +155,101 @@ EXEC dbo.sp_QuickieStore
120
155
/* Search for a specific stored procedure*/
121
156
EXEC dbo .sp_QuickieStore
122
157
@database_name = ' StackOverflow2013' ,
123
- @procedure_name = ' top_percent_sniffer' ;
158
+ @procedure_name = ' top_percent_sniffer' ;
159
+
160
+ /* Search for a specific stored procedure in a specific schema*/
161
+ EXEC dbo .sp_QuickieStore
162
+ @database_name = ' StackOverflow2013' ,
163
+ @procedure_schema = ' not_dbo'
164
+ @procedure_name = ' top_percent_sniffer' ;
124
165
125
166
/* Search for specific query text*/
126
167
EXEC dbo .sp_QuickieStore
127
168
@database_name = ' StackOverflow2013' ,
128
169
@query_text_search = ' WITH Comment'
129
170
171
+ /* Search for specific query text, with brackets automatically escaped.
172
+ Commonly needed when dealing with ORM queries.
173
+ */
174
+ EXEC dbo .sp_QuickieStore
175
+ @database_name = ' StackOverflow2013' ,
176
+ @query_text_search = ' FROM [users] AS [t0]' ,
177
+ @escape_brackets = 1 ;
178
+
179
+ /* By default, We use '\' to escape when @escape_brackets = 1 is set.
180
+ Maybe you want something else.
181
+ Provide it with @escape_character.
182
+ */
183
+ EXEC dbo .sp_QuickieStore
184
+ @database_name = ' StackOverflow2013' ,
185
+ @query_text_search = ' FROM foo\bar AS [t0]' ,
186
+ @escape_character = ' ~'
187
+ @escape_brackets = 1 ;
188
+
189
+
190
+ /* Find every reference to a particular table in your Query Store data, sorted by their execution counts.
191
+ Quite expensive!
192
+ Handy when tuning or finding dependencies, but only as good as what your Query Store has captured.
193
+ Makes use of @get_all_databases = 1, which lets you search all user databases.
194
+ Note the abuse of @start_date. By setting it very far back in the past and leaving @end_date unspecified, we cover all of the data.
195
+ We also abuse @top by setting it very high.
196
+ */
197
+ EXEC dbo .sp_QuickieStore
198
+ @get_all_databases = 1 ,
199
+ @start_date = ' 20000101' ,
200
+ @sort_order = ' executions' ,
201
+ @query_text_search = ' MyTable' ,
202
+ @top = 100 ;
203
+
204
+ /* Filter out certain query text with @query_text_search_not.
205
+ Good for when @query_text_search gets false positives.
206
+ After all, it's only doing string searching.
207
+ */
208
+ EXEC dbo .sp_QuickieStore
209
+ @get_all_databases = 1 ,
210
+ @start_date = ' 20000101' ,
211
+ @sort_order = ' executions' ,
212
+ @query_text_search = ' MyTable' ,
213
+ @query_text_search_not = ' MyTable_secret_backup'
214
+ @top = 100 ;
215
+
216
+
217
+ /* What happened recently on a database?*/
218
+ EXEC dbo .sp_QuickieStore
219
+ @database_name = ' StackOverflow2013'
220
+ @sort_order = ' recent' ;
221
+
222
+ /* What happened recently that referenced my database?
223
+ Good for finding cross-database queries, such as when checking if a database is dead code.
224
+ Don't forget that queries in a database do not need to reference it explicitly!
225
+ */
226
+ EXEC dbo .sp_QuickieStore
227
+ @get_all_databases = 1 ,
228
+ @start_date = ' 20000101' ,
229
+ @sort_order = ' recent' ,
230
+ @query_text_search = ' StackOverflow2013'
231
+ @top = 10 ;
232
+
233
+ /* Only return queries with feedback (2022+)*/
234
+ EXEC dbo .sp_QuickieStore
235
+ @database_name = ' StackOverflow2013' ,
236
+ @only_query_with_feedback = 1 ;
237
+
238
+ /* Only return queries with variants (2022+)*/
239
+ EXEC dbo .sp_QuickieStore
240
+ @database_name = ' StackOverflow2013' ,
241
+ @only_query_with_variants = 1 ;
242
+
243
+ /* Only return queries with forced plans (2022+)*/
244
+ EXEC dbo .sp_QuickieStore
245
+ @database_name = ' StackOverflow2013' ,
246
+ @only_query_with_forced_plans = 1 ;
247
+
248
+ /* Only return queries with forced plan failures (2022+)*/
249
+ EXEC dbo .sp_QuickieStore
250
+ @database_name = ' StackOverflow2013' ,
251
+ @only_query_with_forced_plan_failures = 1 ;
252
+
130
253
/* Only return queries with query hints (2022+)*/
131
254
EXEC dbo .sp_QuickieStore
132
255
@database_name = ' StackOverflow2013' ,
@@ -140,19 +263,38 @@ EXEC dbo.sp_QuickieStore
140
263
@expert_mode = 1 ;
141
264
142
265
143
- /* Use format output to add commas to larger numbers*/
266
+ /* Use format output to add commas to larger numbers
267
+ This is enabled by default.
268
+ */
144
269
EXEC dbo .sp_QuickieStore
145
270
@database_name = ' StackOverflow2013' ,
146
271
@sort_order = ' memory' ,
147
272
@top = 10 ,
148
273
@format_output = 1 ;
149
274
275
+ /* Disable format output to remove commas.*/
276
+ EXEC dbo .sp_QuickieStore
277
+ @database_name = ' StackOverflow2013' ,
278
+ @sort_order = ' memory' ,
279
+ @top = 10 ,
280
+ @format_output = 0 ;
150
281
151
- /* Use wait filter to search for queries responsible for high waits*/
282
+ /* Change the timezone show in your outputs.
283
+ This is only an output-formatting change.
284
+ It does not change how dates are processed.
285
+ */
152
286
EXEC dbo .sp_QuickieStore
153
287
@database_name = ' StackOverflow2013' ,
154
- @wait_filter = ' memory' ,
155
- @sort_order = ' memory' ;
288
+ @timezone = ' Egypt Standard Time' ;
289
+
290
+ /* Debugging something complex?
291
+ Hide the bottom table with @hide_help_table = 1 when you need more room.
292
+ */
293
+ EXEC dbo .sp_QuickieStore
294
+ @database_name = ' StackOverflow2013' ,
295
+ @hide_help_table = 1 ,
296
+ @sort_order = ' latch waits' ,
297
+ @top = 50 ;
156
298
157
299
/* Search by query hashes*/
158
300
EXEC dbo .sp_QuickieStore
@@ -170,6 +312,27 @@ EXEC dbo.sp_QuickieStore
170
312
@include_sql_handles =
171
313
' 0x0900F46AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000,0x0200000AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000' ;
172
314
315
+ /* Search, but ignoring some query hashes*/
316
+ EXEC dbo .sp_QuickieStore
317
+ @ignore_query_hashes = ' 0x1AB614B461F4D769,0x1CD777B461F4D769' ;
318
+
319
+ /* Search, but ignoring some plan hashes*/
320
+ EXEC dbo .sp_QuickieStore
321
+ @ignore_plan_hashes = ' 0x6B84B820B8B38564,0x6B84B999D7B38564' ;
322
+
323
+ /* Search, but ignoring some SQL Handles*/
324
+ EXEC dbo .sp_QuickieStore
325
+ @ignore_sql_handles =
326
+ ' 0x0900F46AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000,0x0200000AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000' ;
327
+
328
+ /* What query hashes have the most plans?
329
+ This sort order is special because it needs to return multiple rows for each of the @top hashes it looks at.
330
+ It is also special because it adds some new columns all the way over on the right of the output.
331
+ */
332
+ EXEC dbo .sp_QuickieStore
333
+ @database_name = ' StackOverflow2013' ,
334
+ @sort_order = ' plan count by hashes' ;
335
+
173
336
/* Check for regressions.
174
337
Specifically, this checks for queries that did more logical reads last week than this week.
175
338
The default dates are helpful here. The default @start_date and @end_date specify last week for us and @regression_baseline_end_date defaults to being one week after @regression_baseline_start_date.
@@ -243,13 +406,23 @@ EXEC dbo.sp_QuickieStore
243
406
@regression_direction = ' absolute' ,
244
407
@regression_baseline_start_date = @TwoWeekAgo;
245
408
409
+ /* Get version info.*/
410
+ DECLARE @version_output varchar (30 ),
411
+ @version_date_output datetime ;
412
+
413
+ EXEC sp_QuickieStore
414
+ @version = @version_output OUTPUT ,
415
+ @version_date = @version_date_output OUTPUT ;
416
+
417
+ SELECT
418
+ Version = @version_output,
419
+ VersionDate = @version_date_output;
246
420
247
421
/* Troubleshoot performance*/
248
422
EXEC dbo .sp_QuickieStore
249
423
@database_name = ' StackOverflow2013' ,
250
424
@troubleshoot_performance = 1 ;
251
425
252
-
253
426
/* Debug dynamic SQL and temp table contents*/
254
427
EXEC dbo .sp_QuickieStore
255
428
@database_name = ' StackOverflow2013' ,
0 commit comments