Skip to content

Commit

Permalink
Fixed issue 26
Browse files Browse the repository at this point in the history
Fixed issue microsoft#26 by adding in steps to create a c:\sql_sample_databases directory.
  • Loading branch information
rgward committed Jun 20, 2022
1 parent 0894e57 commit 1fc35ce
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
25 changes: 13 additions & 12 deletions demos/sqlserver2022/IQP/cefeedback/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ This is a set of steps to see CE feedback in action and how it can improve query

## Demo Steps

1. Create a directory at c:\sql_sample_databases to store backups and files.
1. Download the AdventureWorks2016_EXT sample backup from https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2016_EXT.bak
2. Restore AdventureWorks_EXT sample backup using restore_adventureworks_ext.sql. Modify the file paths as needed on your system.
3. Run create_xevent_seassion.sql to create and start an Extended Events session to view feedback events. Use SSMS in Object Explorer to view the session with Watch Live Data
4. Add an ncl index on City column for Person.Address using create_index_on_city.sql
5. Set dbcompat to 160 and turn on query store using dbcompat160.sql
6. Run a batch to prime CE feedback using cefeedbackquerybatch.sql
7. Run the query a single time to active CE feedback using cefeedbackquery.sql
8. Run the queries in check_query_hints_and_feedback.sql to see if CE feedback is initiated. You should see a statement of PENDING_VALIDATION from the 2nd DMV query
9. Run the query again in cefeedbackquery.sql
10. Run the queries in check_query_hints_and_feedback.sql again and you will see a query hint has been stored and the status in the 2nd DMV is VERIFICATION_PASSED
11. View the XEvent session data to see how feedback was provided and then veried to be faster
12. With the hint now in place, run the queries from the batch to match the number of executions usin cefeedbackquerybatch.sql
13. Using Query Store Reports for Top Resource Consuming Queries to compare the query with different plans with and without the hint. The plan with the hint (now using an Index Scan should be overall faster and consume less CPU)
1. Restore AdventureWorks_EXT sample backup using restore_adventureworks_ext.sql. Modify the file paths as needed on your system.
1. Run create_xevent_seassion.sql to create and start an Extended Events session to view feedback events. Use SSMS in Object Explorer to view the session with Watch Live Data
1. Add an ncl index on City column for Person.Address using create_index_on_city.sql
1. Set dbcompat to 160 and turn on query store using dbcompat160.sql
1. Run a batch to prime CE feedback using cefeedbackquerybatch.sql
1. Run the query a single time to active CE feedback using cefeedbackquery.sql
1. Run the queries in check_query_hints_and_feedback.sql to see if CE feedback is initiated. You should see a statement of PENDING_VALIDATION from the 2nd DMV query
1. Run the query again in cefeedbackquery.sql
1. Run the queries in check_query_hints_and_feedback.sql again and you will see a query hint has been stored and the status in the 2nd DMV is VERIFICATION_PASSED
1. View the XEvent session data to see how feedback was provided and then veried to be faster
1. With the hint now in place, run the queries from the batch to match the number of executions usin cefeedbackquerybatch.sql
1. Using Query Store Reports for Top Resource Consuming Queries to compare the query with different plans with and without the hint. The plan with the hint (now using an Index Scan should be overall faster and consume less CPU)

27 changes: 14 additions & 13 deletions demos/sqlserver2022/IQP/dopfeedback/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ This demo will show you how to see how to get consistent performance with less C
## Steps

1. Execute configmaxdop.sql
2. Copy the WideWorldImporters sample database from https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak to a local directory (The restore script assumes c:\sql_sample_databases)
3. Edit the restorewwi.sql script for the correct paths for the backup and where data and log files should go.
4. Execute the script restorewwi.sql
5. Extend the database by executing populatedata.sql. This will take ~13mins to execute. Because of the large transaction the log will grow to ~30Gb and the user FG will grow to about ~6.5Gb
6. Execute dopfeedback.sql to set QDS settings and db setting for DOP feeback (required for CTP 2.0)
7. Execute proc.sql to create a stored procedure
8. Execute dopexec.sql to create an XEvent session.
9. Use SSMS to Watch the XE session to see Live Data
10. Run workload_index_scan_users.cmd
11. Observe the XEvent data. It will take about 10mins to see XXXX event which means the final DOP setting to achieve stability.
12. Cancel the workload from the cmd script
13. Run dop_query_stats.sql to see the changes in DOP and resulting stats. Not the small decrease in avg duration and decrease in needed CPU
14. Use Top Resource Consuming Queries report and look at Avg Duration and Avg CPU to see the steady decrease until stable.
1. Create a directory at c:\sql_sample_databases to store backups and files.
1. Copy the WideWorldImporters sample database from https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak to a local directory (The restore script assumes c:\sql_sample_databases)
1. Edit the restorewwi.sql script for the correct paths for the backup and where data and log files should go.
1. Execute the script restorewwi.sql
1. Extend the database by executing populatedata.sql. This will take ~13mins to execute. Because of the large transaction the log will grow to ~30Gb and the user FG will grow to about ~6.5Gb
1. Execute dopfeedback.sql to set QDS settings and db setting for DOP feeback (required for CTP 2.0)
1. Execute proc.sql to create a stored procedure
1. Execute dopexec.sql to create an XEvent session.
1. Use SSMS to Watch the XE session to see Live Data
1. Run workload_index_scan_users.cmd
1. Observe the XEvent data. It will take about 10mins to see XXXX event which means the final DOP setting to achieve stability.
1. Cancel the workload from the cmd script
1. Run dop_query_stats.sql to see the changes in DOP and resulting stats. Not the small decrease in avg duration and decrease in needed CPU
1. Use Top Resource Consuming Queries report and look at Avg Duration and Avg CPU to see the steady decrease until stable.
11 changes: 6 additions & 5 deletions demos/sqlserver2022/IQP/psp/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ Follow these steps to demonstrate Parameter Sensitive Plan (PSP) optimization

## Setup the demo

1. Create a directory at c:\sql_sample_databases to store backups and files.
1. Copy WideWorldImporters from https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak (the restore script assumes c:\sql_sample_databases)
2. Restore the WideWorldImporters backup. You can edit and use the **restorewwi.sql** script.
3. Load and execute the **populatedata.sql** script to load more data into the Warehouse.StockItems table. This script will take 5 mins to run
4. Rebuild an index associated with the table with **rebuild_index.sql**
5. Create a new procedure to be used for the workload test using **proc.sql**.
6. Edit your servername in sqlsetup.cmd and execute the script. This will ensure the WideWorldImporters database is at dbcompat 150 and clear the query store.
1. Restore the WideWorldImporters backup. You can edit and use the **restorewwi.sql** script.
1. Load and execute the **populatedata.sql** script to load more data into the Warehouse.StockItems table. This script will take 5 mins to run
1. Rebuild an index associated with the table with **rebuild_index.sql**
1. Create a new procedure to be used for the workload test using **proc.sql**.
1. Edit your servername in sqlsetup.cmd and execute the script. This will ensure the WideWorldImporters database is at dbcompat 150 and clear the query store.

## See a PSP problem for a single query execution.

Expand Down

0 comments on commit 1fc35ce

Please sign in to comment.