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
This demo shows capabilities of Query Store. Usually we demo 3-4 scenarios:
4
4
1. How to turn on and initially configure Query Store
5
5
2. How Query Store collects & exposed data
6
6
3. Detecting and fixing query with plan choice regression
7
7
4. Detecting and fixing workload that is candidate for auto-parametrization
8
8
9
-
**Prerequisites**
9
+
## Prerequisites
10
10
11
11
Restore AdventureWorks2016_EXT database from the provided BAK at https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks.
12
12
13
-
Turn ON and Configure Query Store
14
-
15
-
After restoring the database, go to Properties / Query Store tab.
13
+
After restoring the database AdventureWorks2016_EXT, go to Properties / Query Store tab, turn ON Query Store, and configure it according to best practices in https://docs.microsoft.com/sql/relational-databases/performance/best-practice-with-the-query-store.
16
14
17
15

18
16
19
17
Use docs content to walk through main config settings: https://docs.microsoft.com//sql/relational-databases/performance/best-practice-with-the-query-store#Configure
20
18
21
-
**How Query Store Works**
19
+
### How Query Store Works
22
20
Open ShowBasics.sql script and execute queries individually:
23
21
- Run simple `SELECT * FROM` Part
24
22
- Show where query ends in sys.query_store_query_text, sys.query_store_query, sys.query_store_plan, sys.query_store_runtime_stats
@@ -27,12 +25,13 @@ Open ShowBasics.sql script and execute queries individually:
27
25
- Show what happens with query that gets auto-parametrized. It cannot be searched using the original query text because QDS stores query as parametrized. Hopefully, sys.fn_stmt_sql_handle_from_sql_stmt can be used to track down query using original query text
28
26
- Run `vw_QueryStoreRuntimeInfo` (again custom view) to show main runtime stats combined with query/plan info
29
27
30
-
**Query with plan regression**
28
+
### Query with plan regression
31
29
1. Run QueryStoreSimpleDemo.exe with option R or option S
32
30
2. Open SSMS, analyze and explain - two execution plans that SQL Server use alternately (switches between 2 plan almost randomly). This is known as Parameter Sniffing problem - plan gets generated based on parameter available at the compilation time. When compilation happens frequently and randomly and data is skewed (not all parameter values are uniformly distributed PSP is likely to occur and degradations are common)
33
31
3. Force better plan, explain what happens (SSMS)
34
32
4. Summarize benefits for DBA – fixing performance quickly without knowing details about the query. Fully transparent to running apps
35
-
Detect and fix ad hoc workload that is candidate for parametrization
33
+
34
+
### Detect and fix ad hoc workload that is candidate for parametrization
36
35
1. Run QueryStoreSimpleDemo.exe with option P and let it work for some time (15-20 sec)
37
36
2. Open “Auto-Param Analysis.sql” and run queries from groups (1) and (2). What we see is:
38
37
a. Large number of queries / plan entries, small number of different query/plan hashes indicates queries that are not parametrized although they are good candidates
@@ -45,6 +44,3 @@ b. Relatively big compile time shows that system wastes resources on compilation
45
44
8. Open Open SSMS Top Resource Consuming queries: you’ll see dozen of different queries to tune
46
45
9. (6) show alternative solution – applying forced parametrization for the entire DB. Just mention, as a possible solution
0 commit comments