Skip to content

Commit 355e36a

Browse files
authored
Merge pull request #3389 from VladDBA/dev
Added Help message to sp_BlitzQueryStore
2 parents 111b7ef + 1028ba6 commit 355e36a

File tree

1 file changed

+251
-2
lines changed

1 file changed

+251
-2
lines changed

sp_BlitzQueryStore.sql

Lines changed: 251 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ IF (SELECT CONVERT(NVARCHAR(128), SERVERPROPERTY ('EDITION'))) <> 'SQL Azure'
118118

119119
IF @Help = 1
120120
BEGIN
121-
122-
SELECT N'You have requested assistance. It will arrive as soon as humanly possible.' AS [Take four red capsules, help is on the way];
123121

124122
PRINT N'
125123
sp_BlitzQueryStore from http://FirstResponderKit.org
@@ -163,6 +161,257 @@ IF @Help = 1
163161
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
164162
SOFTWARE.
165163
';
164+
/*Parameter info*/
165+
SELECT N'@Help' AS [Parameter Name] ,
166+
N'BIT' AS [Data Type] ,
167+
N'0' AS [Default Value],
168+
N'Displays this help message.' AS [Parameter Description]
169+
UNION ALL
170+
SELECT N'@DatabaseName',
171+
N'NVARCHAR(128)',
172+
N'NULL',
173+
N'The name of the database you want to check the query store for.'
174+
UNION ALL
175+
SELECT N'@Top',
176+
N'INT',
177+
N'3',
178+
N'The number of records to retrieve and analyze from the query store. The following system views are used: query_store_query, query_context_settings, query_store_wait_stats, query_store_runtime_stats,query_store_plan.'
179+
180+
UNION ALL
181+
SELECT N'@StartDate',
182+
N'DATETIME2(7)',
183+
N'NULL',
184+
N'Get query store info starting from this date. When not specified, sp_BlitzQueryStore gets info from the last 7 days'
185+
UNION ALL
186+
SELECT N'@EndDate',
187+
N'DATETIME2(7)',
188+
N'NULL',
189+
N'Get query store info until this date. When not specified, sp_BlitzQueryStore gets info from the last 7 days'
190+
UNION ALL
191+
SELECT N'@MinimumExecutionCount',
192+
N'INT',
193+
N'NULL',
194+
N'When a value is specified, sp_BlitzQueryStore gets info for queries where count_executions >= @MinimumExecutionCount'
195+
UNION ALL
196+
SELECT N'@DurationFilter',
197+
N'DECIMAL(38,4)',
198+
N'NULL',
199+
N'Time unit - seconds. When a value is specified, sp_BlitzQueryStore gets info for queries where the average duration >= @DurationFilter'
200+
UNION ALL
201+
SELECT N'@StoredProcName',
202+
N'NVARCHAR(128)',
203+
N'NULL',
204+
N'Get information for this specific stored procedure.'
205+
UNION ALL
206+
SELECT N'@Failed',
207+
N'BIT',
208+
N'0',
209+
N'When set to 1, only information about failed queries is returned.'
210+
UNION ALL
211+
SELECT N'@PlanIdFilter',
212+
N'INT',
213+
N'NULL',
214+
N'The ID of the plan you want to check for.'
215+
UNION ALL
216+
SELECT N'@QueryIdFilter',
217+
N'INT',
218+
N'NULL',
219+
N'The ID of the query you want to check for.'
220+
UNION ALL
221+
SELECT N'@ExportToExcel',
222+
N'BIT',
223+
N'0',
224+
N'When set to 1, prepares output for exporting to Excel. Newlines and additional whitespace are removed from query text and the execution plan is not displayed.'
225+
UNION ALL
226+
SELECT N'@HideSummary',
227+
N'BIT',
228+
N'0',
229+
N'When set to 1, hides the findings summary result set.'
230+
UNION ALL
231+
SELECT N'@SkipXML',
232+
N'BIT',
233+
N'0',
234+
N'When set to 1, missing_indexes, implicit_conversion_info, cached_execution_parameters, are not returned. Does not affect query_plan_xml'
235+
UNION ALL
236+
SELECT N'@Debug',
237+
N'BIT',
238+
N'0',
239+
N'Setting this to 1 will print dynamic SQL and select data from all tables used.'
240+
UNION ALL
241+
SELECT N'@ExpertMode',
242+
N'BIT',
243+
N'0',
244+
N'When set to 1, more checks are done. Examples: many to many merge joins, row goals, adaptive joins, stats info, bad scans and plan forcing, computed columns that reference scalar UDFs.'
245+
UNION ALL
246+
SELECT N'@VersionCheckMode',
247+
N'BIT',
248+
N'0',
249+
N'Outputs the version number and date.'
250+
251+
/* Column definitions */
252+
SELECT 'database_name' AS [Column Name],
253+
'NVARCHAR(258)' AS [Data Type],
254+
'The name of the database where the plan was encountered.' AS [Column Description]
255+
UNION ALL
256+
SELECT 'query_cost',
257+
'FLOAT',
258+
'The cost of the execution plan in query bucks.'
259+
UNION ALL
260+
SELECT 'plan_id',
261+
'BIGINT',
262+
'The ID of the plan from sys.query_store_plan.'
263+
UNION ALL
264+
SELECT 'query_id',
265+
'BIGINT',
266+
'The ID of the query from sys.query_store_query.'
267+
UNION ALL
268+
SELECT 'query_id_all_plan_ids',
269+
'VARCHAR(8000)',
270+
'Comma-separated list of all query plan IDs associated with this query.'
271+
UNION ALL
272+
SELECT 'query_sql_text',
273+
'NVARCHAR(MAX)',
274+
'The text of the query, as provided by the user/app. Includes whitespaces, hints and comments. Comments and spaces before and after the query text are ignored.'
275+
UNION ALL
276+
SELECT 'proc_or_function_name',
277+
'NVARCHAR(258)',
278+
'If the query is part of a function/stored procedure, you''ll see here the name of its parent object.'
279+
UNION ALL
280+
SELECT 'query_plan_xml',
281+
' XML',
282+
'The query plan. Click to display a graphical plan.'
283+
UNION ALL
284+
SELECT 'warnings',
285+
'VARCHAR(MAX)',
286+
'A list of individual warnings generated by this query.'
287+
UNION ALL
288+
SELECT 'pattern',
289+
'NVARCHAR(512)',
290+
'A list of performance related patterns identified for this query.'
291+
UNION ALL
292+
SELECT 'parameter_sniffing_symptoms',
293+
'NVARCHAR(4000)',
294+
'A list of all the identified symptoms that are usually indicators of parameter sniffing.'
295+
UNION ALL
296+
SELECT 'last_force_failure_reason_desc',
297+
'NVARCHAR(258)',
298+
'Reason why plan forcing failed. NONE if plan isn''t forced.'
299+
UNION ALL
300+
SELECT 'top_three_waits',
301+
'NVARCHAR(MAX)',
302+
'The top 3 wait types, and their times in milliseconds, recorded for this query.'
303+
UNION ALL
304+
SELECT 'missing_indexes',
305+
'XML',
306+
'Missing index recommendations retrieved from the query plan.'
307+
UNION ALL
308+
SELECT 'implicit_conversion_info',
309+
'XML',
310+
'Information about the implicit conversion warnings,if any, retrieved from the query plan.'
311+
UNION ALL
312+
SELECT 'cached_execution_parameters',
313+
'XML',
314+
'Names, data types, and values for the parameters used when the query plan was compiled.'
315+
UNION ALL
316+
SELECT 'count_executions ',
317+
'BIGINT',
318+
'The number of executions of this particular query.'
319+
UNION ALL
320+
SELECT 'count_compiles',
321+
'BIGINT',
322+
'The number of plan compilations for this particular query.'
323+
UNION ALL
324+
SELECT 'total_cpu_time',
325+
'BIGINT',
326+
'Total CPU time, reported in milliseconds, that was consumed by all executions of this query.'
327+
UNION ALL
328+
SELECT 'avg_cpu_time ',
329+
'BIGINT',
330+
'Average CPU time, reported in milliseconds, consumed by each execution of this query.'
331+
UNION ALL
332+
SELECT 'total_duration',
333+
'BIGINT',
334+
'Total elapsed time, reported in milliseconds, consumed by all executions of this query.'
335+
UNION ALL
336+
SELECT 'avg_duration',
337+
'BIGINT',
338+
'Average elapsed time, reported in milliseconds, consumed by each execution of this query.'
339+
UNION ALL
340+
SELECT 'total_logical_io_reads',
341+
'BIGINT',
342+
'Total logical reads, reported in MB, performed by this query.'
343+
UNION ALL
344+
SELECT 'avg_logical_io_reads',
345+
'BIGINT',
346+
'Average logical reads, reported in MB, performed by each execution of this query.'
347+
UNION ALL
348+
SELECT 'total_physical_io_reads',
349+
'BIGINT',
350+
'Total physical reads, reported in MB, performed by this query.'
351+
UNION ALL
352+
SELECT 'avg_physical_io_reads',
353+
'BIGINT',
354+
'Average physical reads, reported in MB, performed by each execution of this query.'
355+
UNION ALL
356+
SELECT 'total_logical_io_writes',
357+
'BIGINT',
358+
'Total logical writes, reported in MB, performed by this query.'
359+
UNION ALL
360+
SELECT 'avg_logical_io_writes',
361+
'BIGINT',
362+
'Average logical writes, reported in MB, performed by each execution of this query.'
363+
UNION ALL
364+
SELECT 'total_rowcount',
365+
'BIGINT',
366+
'Total number of rows returned for all executions of this query.'
367+
UNION ALL
368+
SELECT 'avg_rowcount',
369+
'BIGINT',
370+
'Average number of rows returned by each execution of this query.'
371+
UNION ALL
372+
SELECT 'total_query_max_used_memory',
373+
'DECIMAL(38,2)',
374+
'Total max memory grant, reported in MB, used by this query.'
375+
UNION ALL
376+
SELECT 'avg_query_max_used_memory',
377+
'DECIMAL(38,2)',
378+
'Average max memory grant, reported in MB, used by each execution of this query.'
379+
UNION ALL
380+
SELECT 'total_tempdb_space_used',
381+
'DECIMAL(38,2)',
382+
'Total tempdb space, reported in MB, used by this query.'
383+
UNION ALL
384+
SELECT 'avg_tempdb_space_used',
385+
'DECIMAL(38,2)',
386+
'Average tempdb space, reported in MB, used by each execution of this query.'
387+
UNION ALL
388+
SELECT 'total_log_bytes_used',
389+
'DECIMAL(38,2)',
390+
'Total number of bytes in the database log used by this query.'
391+
UNION ALL
392+
SELECT 'avg_log_bytes_used',
393+
'DECIMAL(38,2)',
394+
'Average number of bytes in the database log used by each execution of this query.'
395+
UNION ALL
396+
SELECT 'total_num_physical_io_reads',
397+
'DECIMAL(38,2)',
398+
'Total number of physical I/O reads performed by this query (expressed as a number of read I/O operations).'
399+
UNION ALL
400+
SELECT 'avg_num_physical_io_reads',
401+
'DECIMAL(38,2)',
402+
'Average number of physical I/O reads performed by each execution of this query (expressed as a number of read I/O operations).'
403+
UNION ALL
404+
SELECT 'first_execution_time',
405+
'DATETIME2',
406+
'First execution time for this query within the aggregation interval. This is the end time of the query execution.'
407+
UNION ALL
408+
SELECT 'last_execution_time',
409+
'DATETIME2',
410+
'Last execution time for this query within the aggregation interval. This is the end time of the query execution.'
411+
UNION ALL
412+
SELECT 'context_settings',
413+
'NVARCHAR(512)',
414+
'Contains information about context settings associated with this query.';
166415
RETURN;
167416

168417
END;

0 commit comments

Comments
 (0)