Skip to content

Commit d6b9c3e

Browse files
authored
Update README.md
1 parent 8dd44e5 commit d6b9c3e

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
**Query Store demo**
1+
## Query Store demo
22

33
This demo shows capabilities of Query Store. Usually we demo 3-4 scenarios:
44
1. How to turn on and initially configure Query Store
55
2. How Query Store collects & exposed data
66
3. Detecting and fixing query with plan choice regression
77
4. Detecting and fixing workload that is candidate for auto-parametrization
88

9-
**Prerequisites**
9+
## Prerequisites
1010

1111
Restore AdventureWorks2016_EXT database from the provided BAK at https://github.com/Microsoft/sql-server-samples/releases/tag/adventureworks.
1212

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.
1614

1715
![Query Store in SSMS](./QS_SSMS.png)
1816

1917
Use docs content to walk through main config settings: https://docs.microsoft.com//sql/relational-databases/performance/best-practice-with-the-query-store#Configure
2018

21-
**How Query Store Works**
19+
### How Query Store Works
2220
Open ShowBasics.sql script and execute queries individually:
2321
- Run simple `SELECT * FROM` Part
2422
- 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:
2725
- 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
2826
- Run `vw_QueryStoreRuntimeInfo` (again custom view) to show main runtime stats combined with query/plan info
2927

30-
**Query with plan regression**
28+
### Query with plan regression
3129
1. Run QueryStoreSimpleDemo.exe with option R or option S
3230
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)
3331
3. Force better plan, explain what happens (SSMS)
3432
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
3635
1. Run QueryStoreSimpleDemo.exe with option P and let it work for some time (15-20 sec)
3736
2. Open “Auto-Param Analysis.sql” and run queries from groups (1) and (2). What we see is:
3837
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
4544
8. Open Open SSMS Top Resource Consuming queries: you’ll see dozen of different queries to tune
4645
9. (6) show alternative solution – applying forced parametrization for the entire DB. Just mention, as a possible solution
4746
10. Run (7) to reset DB to initial state.
48-
49-
50-

0 commit comments

Comments
 (0)