Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #496

Merged
merged 21 commits into from
Oct 29, 2024
Merged

Dev #496

Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c8b3684
Added ability to check queries against a baseline for changes in @sor…
ReeceGoding Oct 13, 2024
8dbf30a
Cleared whitespace.
ReeceGoding Oct 13, 2024
cc47eb2
Fixed bug causing the waits sort orders to fail outside of regression…
ReeceGoding Oct 15, 2024
2cb981f
Clarified how @get_all_databases and @database_name work with system …
ReeceGoding Oct 20, 2024
c0b7e63
Merge pull request #488 from ReeceGoding/patch-9
erikdarlingdata Oct 20, 2024
84adb01
Merge branch 'dev' into QuickieStoreRegressionMerge
ReeceGoding Oct 22, 2024
60c5558
@regression_direction = 'absolute' did not make regressions sort diff…
ReeceGoding Oct 22, 2024
0b7f316
Added @Regression parameters to README and examples.
ReeceGoding Oct 22, 2024
ddb4e3c
Minor edits to examples.
ReeceGoding Oct 22, 2024
312defb
Merge pull request #486 from ReeceGoding/QuickieStoreRegressionMerge
erikdarlingdata Oct 22, 2024
6b8478a
Update sp_IndexCleanup BETA.sql
erikdarlingdata Oct 23, 2024
31db6b1
QuickieStore Examples: Minor wording edits.
ReeceGoding Oct 23, 2024
9a8d62b
Merge pull request #491 from ReeceGoding/patch-10
erikdarlingdata Oct 23, 2024
5c7d979
Made last_ columns report the actual lasts, rather than the maximum o…
ReeceGoding Oct 23, 2024
10030f9
Update sp_PressureDetector.sql
erikdarlingdata Oct 24, 2024
fe726cc
Merge pull request #492 from ReeceGoding/CorrectLastColumns
erikdarlingdata Oct 28, 2024
4876870
Validated @query_execution_type_desc's value. Added the valid values …
ReeceGoding Oct 28, 2024
c5e95ff
Merge pull request #494 from ReeceGoding/execution_type_desc
erikdarlingdata Oct 28, 2024
6f66b44
Added every missing parameter to the sp_QuickieStore Examples file.
ReeceGoding Oct 28, 2024
a0ec444
Merge pull request #495 from ReeceGoding/MoreExamples
erikdarlingdata Oct 28, 2024
248856e
Merge branch 'main' into dev
erikdarlingdata Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added every missing parameter to the sp_QuickieStore Examples file.
ReeceGoding committed Oct 28, 2024
commit 6f66b4468977b71c4ea1b64f5202b636fc411542
187 changes: 180 additions & 7 deletions sp_QuickieStore/Examples.sql
Original file line number Diff line number Diff line change
@@ -24,13 +24,21 @@ https://github.com/erikdarlingdata/DarlingData
EXEC dbo.sp_QuickieStore
@help = 1;

/*The default is finding the top 10 sorted by CPU in the last seven days.*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013';

/*Find top 10 sorted by memory*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@sort_order = 'memory',
@top = 10;
@top = 10;

/*Find top 10 in each user database sorted by cpu*/
EXEC dbo.sp_QuickieStore
@get_all_databases = 1,
@sort_order = 'cpu',
@top = 10;

/*Search for specific query_ids*/
EXEC dbo.sp_QuickieStore
@@ -72,6 +80,13 @@ EXEC dbo.sp_QuickieStore
@start_date = '20210320',
@end_date = '20210321';

/*Filter out weekends and anything outside of your choice of hours.*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@workdays = 1,
@work_start = '8am',
@work_end = '6pm'


/*Search for queries with a minimum execution count*/
EXEC dbo.sp_QuickieStore
@@ -87,6 +102,26 @@ EXEC dbo.sp_QuickieStore
@duration_ms = 10000;


/*Use wait filter to search for queries responsible for high waits*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@wait_filter = 'memory',
@sort_order = 'memory';

/*We also support using wait types as a sort order, see the documentation for the full list.
The wait-related sort orders are special because we add an extra column for the duration of the wait type you are asking for.
It's all the way over on the right.
*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@sort_order = 'memory waits';

/*You can also sort by total wait time across all waits. */
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@sort_order = 'total waits';


/*Search for queries with a specific execution type
When we do not provide this parameter, we grab all types.
This example grabs "aborted" queries, which are queries cancelled by the client.
@@ -120,13 +155,101 @@ EXEC dbo.sp_QuickieStore
/*Search for a specific stored procedure*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@procedure_name = 'top_percent_sniffer';
@procedure_name = 'top_percent_sniffer';

/*Search for a specific stored procedure in a specific schema*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@procedure_schema = 'not_dbo'
@procedure_name = 'top_percent_sniffer';

/*Search for specific query text*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@query_text_search = 'WITH Comment'

/*Search for specific query text, with brackets automatically escaped.
Commonly needed when dealing with ORM queries.
*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@query_text_search = 'FROM [users] AS [t0]',
@escape_brackets = 1;

/*By default, We use '\' to escape when @escape_brackets = 1 is set.
Maybe you want something else.
Provide it with @escape_character.
*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@query_text_search = 'FROM foo\bar AS [t0]',
@escape_character = '~'
@escape_brackets = 1;


/*Find every reference to a particular table in your Query Store data, sorted by their execution counts.
Quite expensive!
Handy when tuning or finding dependencies, but only as good as what your Query Store has captured.
Makes use of @get_all_databases = 1, which lets you search all user databases.
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.
We also abuse @top by setting it very high.
*/
EXEC dbo.sp_QuickieStore
@get_all_databases = 1,
@start_date = '20000101',
@sort_order = 'executions',
@query_text_search = 'MyTable',
@top = 100;

/*Filter out certain query text with @query_text_search_not.
Good for when @query_text_search gets false positives.
After all, it's only doing string searching.
*/
EXEC dbo.sp_QuickieStore
@get_all_databases = 1,
@start_date = '20000101',
@sort_order = 'executions',
@query_text_search = 'MyTable',
@query_text_search_not = 'MyTable_secret_backup'
@top = 100;


/*What happened recently on a database?*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013'
@sort_order = 'recent';

/*What happened recently that referenced my database?
Good for finding cross-database queries, such as when checking if a database is dead code.
Don't forget that queries in a database do not need to reference it explicitly!
*/
EXEC dbo.sp_QuickieStore
@get_all_databases = 1,
@start_date = '20000101',
@sort_order = 'recent',
@query_text_search = 'StackOverflow2013'
@top = 10;

/*Only return queries with feedback (2022+)*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@only_query_with_feedback = 1;

/*Only return queries with variants (2022+)*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@only_query_with_variants = 1;

/*Only return queries with forced plans (2022+)*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@only_query_with_forced_plans = 1;

/*Only return queries with forced plan failures (2022+)*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@only_query_with_forced_plan_failures = 1;

/*Only return queries with query hints (2022+)*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@@ -140,19 +263,38 @@ EXEC dbo.sp_QuickieStore
@expert_mode = 1;


/*Use format output to add commas to larger numbers*/
/*Use format output to add commas to larger numbers
This is enabled by default.
*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@sort_order = 'memory',
@top = 10,
@format_output = 1;

/*Disable format output to remove commas.*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@sort_order = 'memory',
@top = 10,
@format_output = 0;

/*Use wait filter to search for queries responsible for high waits*/
/*Change the timezone show in your outputs.
This is only an output-formatting change.
It does not change how dates are processed.
*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@wait_filter = 'memory',
@sort_order = 'memory';
@timezone = 'Egypt Standard Time';

/*Debugging something complex?
Hide the bottom table with @hide_help_table = 1 when you need more room.
*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@hide_help_table = 1,
@sort_order = 'latch waits',
@top = 50;

/*Search by query hashes*/
EXEC dbo.sp_QuickieStore
@@ -170,6 +312,27 @@ EXEC dbo.sp_QuickieStore
@include_sql_handles =
'0x0900F46AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000,0x0200000AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000';

/*Search, but ignoring some query hashes*/
EXEC dbo.sp_QuickieStore
@ignore_query_hashes = '0x1AB614B461F4D769,0x1CD777B461F4D769';

/*Search, but ignoring some plan hashes*/
EXEC dbo.sp_QuickieStore
@ignore_plan_hashes = '0x6B84B820B8B38564,0x6B84B999D7B38564';

/*Search, but ignoring some SQL Handles*/
EXEC dbo.sp_QuickieStore
@ignore_sql_handles =
'0x0900F46AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000,0x0200000AC89E66DF744C8A0AD4FD3D3306B90000000000000000000000000000000000000000000000000000';

/*What query hashes have the most plans?
This sort order is special because it needs to return multiple rows for each of the @top hashes it looks at.
It is also special because it adds some new columns all the way over on the right of the output.
*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@sort_order = 'plan count by hashes';

/*Check for regressions.
Specifically, this checks for queries that did more logical reads last week than this week.
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
@regression_direction = 'absolute',
@regression_baseline_start_date = @TwoWeekAgo;

/*Get version info.*/
DECLARE @version_output varchar(30),
@version_date_output datetime;

EXEC sp_QuickieStore
@version = @version_output OUTPUT,
@version_date = @version_date_output OUTPUT;

SELECT
Version = @version_output,
VersionDate = @version_date_output;

/*Troubleshoot performance*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',
@troubleshoot_performance = 1;


/*Debug dynamic SQL and temp table contents*/
EXEC dbo.sp_QuickieStore
@database_name = 'StackOverflow2013',