SlideShare a Scribd company logo
1 of 17
Download to read offline
Using Query Store to
Understand and Control
Query Performance
Goals
• Learn the kinds of data that query store collects in support of
knowledge about query performance
• Understand the mechanisms of control that are offered to fine tune
Query Store data collection
• Comprehend the ability to take control of query behaviors through
plan forcing and hints
DevOps Advocate
Microsoft Data Platform MVP
AWS Community Builder
@gfritchey
grant@scarydba.com
scarydba.com
Query Store Functionality
• Individual database setting
• On by default in Azure SQL Database and SQL Server 2022
• Asynchronous data collection
• First to memory
• Then to disk
• Basis of data is the query
• A query has one or more plans
• A query has runtime metrics
• A query experiences waits
• Data collected before and after query execution
How Query Store Works: Before Execution
T-SQL
Query
Query Optimizer Execution Plan
Plan Cache
Asynchronous
Data Collection
Query Store
Memory
Asynchronous
Data Writes
Query Store Data
Query Execution
How Query Store Works: After Execution
Results
Asynchronous
Data Collection
Query Store Memory
Asynchronous
Data Writes
Query Store Data
Query Execution
Data Query Store Collects
• Query
• Including T-SQL text
• No parameter values… but
• Execution plan
• Plan w/o runtime values (AKA “Estimated Plan”)
• Runtime metrics
• Aggregated
• Multiple aggregates
• Wait statistics
• Aggregated
• Multiple aggregates
Data Is Stored in System Views
• Sys.query_context_settings – information about the settings for the query,
including things like ANSI settings
• Sys.query_store_query – properties around the query such as hash, count
of compiles, last compile duration, object_id & more
• Sys.query_store_query_text – the T-SQL for the query itself
• Sys.query_store_plan – execution plans and properties around them
• Sys.query_store_runtime_stats_interval – the defined start & stop time of
runtime data aggregations
• Sys.query_store_runtime_stats – the aggregated information like average
execution time, standard deviation, reads, writes, etc.
• Sys.query_store_wait_stats – the aggregated wait statistics for the query &
plan in question
Controlling Query Store: Basics
• Enable/Disable Query Store
• Also READ ONLY
• Data flush interval (default 15 minutes)
• Max storage (varies per version)
• Aggregation interval length (default 60 minutes)
• Cleanup mechanisms (both days & size-based cleanup)
Controlling Query Store: Data Collection
• Defaults vary by version
• Modes:
• All – simple, all queries, probably not the safest approach
• Auto – “capture queries based on resource consumption”, 3 executions or
longer than 1 second
• None – Query Store is enabled, but doesn’t capture new queries
• Custom – 2019+
• EXECUTION_COUNT
• TOTAL_COMPILE_CPU_TIME
• TOTAL_EXECUTION_CPU_TIME_MS
• STALE_CAPTURE_POLICY_THRESHOLD
Query Store Reporting and GUI
Plan Forcing
• Forcing execution plans
• T-SQL
• GUI
• Forcing query hints
• T-SQL
• Optimized plan forcing
Demo
Some Suggested Best Practices
• Monitor data size closely
• Data capture should be Auto or, better still, Custom
• Enable TraceFlags 7752 (prior to 2019) and 7745
• Minimize your historical data
• Regularly check Query Store status
• Where possible, avoid non-parameterized queries
• Use ALTER instead of DROP/CREATE where you can
Why You Need Query Store
• Performance data collection with unique data
• Ability to force plans
• As an aid to upgrades
• Basis for most Intelligent Query Processing
• Traditional query tuning and performance troubleshooting
Additional Resources
• Query Store for SQL Server 2019 – Tracy Boggiano, Grant Fritchey
• dbaTools
• SQL Server 2022 Query Performance Tuning – Grant Fritchey
• Best Practices With Query Store – Erin Stellato
• Best Practices With Query Store - Microsoft
DevOps Advocate
Microsoft Data Platform MVP
AWS Community Builder
@gfritchey
grant@scarydba.com
scarydba.com

More Related Content

Similar to Using Query Store to Understand and Control Query Performance

SQL Server 2017 - Adaptive Query Processing and Automatic Query Tuning
SQL Server 2017 - Adaptive Query Processing and Automatic Query TuningSQL Server 2017 - Adaptive Query Processing and Automatic Query Tuning
SQL Server 2017 - Adaptive Query Processing and Automatic Query TuningJavier Villegas
 
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts
 
4. (mjk) extreme performance 2
4. (mjk) extreme performance 24. (mjk) extreme performance 2
4. (mjk) extreme performance 2Doina Draganescu
 
Choosing the Right Business Intelligence Tools for Your Data and Architectura...
Choosing the Right Business Intelligence Tools for Your Data and Architectura...Choosing the Right Business Intelligence Tools for Your Data and Architectura...
Choosing the Right Business Intelligence Tools for Your Data and Architectura...Victor Holman
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksYoung Alista
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksTony Nguyen
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksFraboni Ec
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksLuis Goldster
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksHoang Nguyen
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksHarry Potter
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksJames Wong
 
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbeganKoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbeganTobias Koprowski
 
Oracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance TuningOracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance TuningOracleTrainings
 
The Google BigQuery Story: Optimizing 25PB Storage
The Google BigQuery Story: Optimizing 25PB StorageThe Google BigQuery Story: Optimizing 25PB Storage
The Google BigQuery Story: Optimizing 25PB StorageIvan Kosianenko
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1sqlserver.co.il
 
Database Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDatabase Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDAGEOP LTD
 
Bb world 2012 using database statistics to make capacity planning decisions...
Bb world 2012   using database statistics to make capacity planning decisions...Bb world 2012   using database statistics to make capacity planning decisions...
Bb world 2012 using database statistics to make capacity planning decisions...Geoff Mower
 

Similar to Using Query Store to Understand and Control Query Performance (20)

SQL Server 2017 - Adaptive Query Processing and Automatic Query Tuning
SQL Server 2017 - Adaptive Query Processing and Automatic Query TuningSQL Server 2017 - Adaptive Query Processing and Automatic Query Tuning
SQL Server 2017 - Adaptive Query Processing and Automatic Query Tuning
 
SQLDay2013_MarcinSzeliga_StoredProcedures
SQLDay2013_MarcinSzeliga_StoredProceduresSQLDay2013_MarcinSzeliga_StoredProcedures
SQLDay2013_MarcinSzeliga_StoredProcedures
 
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New Features
 
Query optimization
Query optimizationQuery optimization
Query optimization
 
4. (mjk) extreme performance 2
4. (mjk) extreme performance 24. (mjk) extreme performance 2
4. (mjk) extreme performance 2
 
Choosing the Right Business Intelligence Tools for Your Data and Architectura...
Choosing the Right Business Intelligence Tools for Your Data and Architectura...Choosing the Right Business Intelligence Tools for Your Data and Architectura...
Choosing the Right Business Intelligence Tools for Your Data and Architectura...
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbeganKoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
 
Oracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance TuningOracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance Tuning
 
The Google BigQuery Story: Optimizing 25PB Storage
The Google BigQuery Story: Optimizing 25PB StorageThe Google BigQuery Story: Optimizing 25PB Storage
The Google BigQuery Story: Optimizing 25PB Storage
 
Performance tuning in sql server
Performance tuning in sql serverPerformance tuning in sql server
Performance tuning in sql server
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1
 
Database Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDatabase Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance Analysis
 
Bb world 2012 using database statistics to make capacity planning decisions...
Bb world 2012   using database statistics to make capacity planning decisions...Bb world 2012   using database statistics to make capacity planning decisions...
Bb world 2012 using database statistics to make capacity planning decisions...
 

More from Grant Fritchey

Migrating To PostgreSQL
Migrating To PostgreSQLMigrating To PostgreSQL
Migrating To PostgreSQLGrant Fritchey
 
PostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and AlertingPostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and AlertingGrant Fritchey
 
Automating Database Deployments Using Azure DevOps
Automating Database Deployments Using Azure DevOpsAutomating Database Deployments Using Azure DevOps
Automating Database Deployments Using Azure DevOpsGrant Fritchey
 
Learn To Effectively Use Extended Events_Techorama.pdf
Learn To Effectively Use Extended Events_Techorama.pdfLearn To Effectively Use Extended Events_Techorama.pdf
Learn To Effectively Use Extended Events_Techorama.pdfGrant Fritchey
 
You Should Be Standing Here: Learn How To Present a Session
You Should Be Standing Here: Learn How To Present a SessionYou Should Be Standing Here: Learn How To Present a Session
You Should Be Standing Here: Learn How To Present a SessionGrant Fritchey
 
Redgate Community Circle: Tools For SQL Server Performance Tuning
Redgate Community Circle: Tools For SQL Server Performance TuningRedgate Community Circle: Tools For SQL Server Performance Tuning
Redgate Community Circle: Tools For SQL Server Performance TuningGrant Fritchey
 
10 Steps To Global Data Compliance
10 Steps To Global Data Compliance10 Steps To Global Data Compliance
10 Steps To Global Data ComplianceGrant Fritchey
 
Time to Use the Columnstore Index
Time to Use the Columnstore IndexTime to Use the Columnstore Index
Time to Use the Columnstore IndexGrant Fritchey
 
Introduction to SQL Server in Containers
Introduction to SQL Server in ContainersIntroduction to SQL Server in Containers
Introduction to SQL Server in ContainersGrant Fritchey
 
SQL Injection: How It Works, How to Stop It
SQL Injection: How It Works, How to Stop ItSQL Injection: How It Works, How to Stop It
SQL Injection: How It Works, How to Stop ItGrant Fritchey
 
Privacy and Protection in the World of Database DevOps
Privacy and Protection in the World of Database DevOpsPrivacy and Protection in the World of Database DevOps
Privacy and Protection in the World of Database DevOpsGrant Fritchey
 
SQL Server Tools for Query Tuning
SQL Server Tools for Query TuningSQL Server Tools for Query Tuning
SQL Server Tools for Query TuningGrant Fritchey
 
Extending DevOps to SQL Server
Extending DevOps to SQL ServerExtending DevOps to SQL Server
Extending DevOps to SQL ServerGrant Fritchey
 
Introducing Azure SQL Data Warehouse
Introducing Azure SQL Data WarehouseIntroducing Azure SQL Data Warehouse
Introducing Azure SQL Data WarehouseGrant Fritchey
 
Introducing Azure Databases
Introducing Azure DatabasesIntroducing Azure Databases
Introducing Azure DatabasesGrant Fritchey
 
Statistis, Row Counts, Execution Plans and Query Tuning
Statistis, Row Counts, Execution Plans and Query TuningStatistis, Row Counts, Execution Plans and Query Tuning
Statistis, Row Counts, Execution Plans and Query TuningGrant Fritchey
 
Understanding Your Servers, All Your Servers
Understanding Your Servers, All Your ServersUnderstanding Your Servers, All Your Servers
Understanding Your Servers, All Your ServersGrant Fritchey
 
Changing Your Habits: Tips to Tune Your T-SQL
Changing Your Habits: Tips to Tune Your T-SQLChanging Your Habits: Tips to Tune Your T-SQL
Changing Your Habits: Tips to Tune Your T-SQLGrant Fritchey
 
Azure SQL Database for the Earthed DBA
Azure SQL Database for the Earthed DBAAzure SQL Database for the Earthed DBA
Azure SQL Database for the Earthed DBAGrant Fritchey
 

More from Grant Fritchey (20)

Migrating To PostgreSQL
Migrating To PostgreSQLMigrating To PostgreSQL
Migrating To PostgreSQL
 
PostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and AlertingPostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and Alerting
 
Automating Database Deployments Using Azure DevOps
Automating Database Deployments Using Azure DevOpsAutomating Database Deployments Using Azure DevOps
Automating Database Deployments Using Azure DevOps
 
Learn To Effectively Use Extended Events_Techorama.pdf
Learn To Effectively Use Extended Events_Techorama.pdfLearn To Effectively Use Extended Events_Techorama.pdf
Learn To Effectively Use Extended Events_Techorama.pdf
 
You Should Be Standing Here: Learn How To Present a Session
You Should Be Standing Here: Learn How To Present a SessionYou Should Be Standing Here: Learn How To Present a Session
You Should Be Standing Here: Learn How To Present a Session
 
Redgate Community Circle: Tools For SQL Server Performance Tuning
Redgate Community Circle: Tools For SQL Server Performance TuningRedgate Community Circle: Tools For SQL Server Performance Tuning
Redgate Community Circle: Tools For SQL Server Performance Tuning
 
10 Steps To Global Data Compliance
10 Steps To Global Data Compliance10 Steps To Global Data Compliance
10 Steps To Global Data Compliance
 
Time to Use the Columnstore Index
Time to Use the Columnstore IndexTime to Use the Columnstore Index
Time to Use the Columnstore Index
 
Introduction to SQL Server in Containers
Introduction to SQL Server in ContainersIntroduction to SQL Server in Containers
Introduction to SQL Server in Containers
 
DevOps for the DBA
DevOps for the DBADevOps for the DBA
DevOps for the DBA
 
SQL Injection: How It Works, How to Stop It
SQL Injection: How It Works, How to Stop ItSQL Injection: How It Works, How to Stop It
SQL Injection: How It Works, How to Stop It
 
Privacy and Protection in the World of Database DevOps
Privacy and Protection in the World of Database DevOpsPrivacy and Protection in the World of Database DevOps
Privacy and Protection in the World of Database DevOps
 
SQL Server Tools for Query Tuning
SQL Server Tools for Query TuningSQL Server Tools for Query Tuning
SQL Server Tools for Query Tuning
 
Extending DevOps to SQL Server
Extending DevOps to SQL ServerExtending DevOps to SQL Server
Extending DevOps to SQL Server
 
Introducing Azure SQL Data Warehouse
Introducing Azure SQL Data WarehouseIntroducing Azure SQL Data Warehouse
Introducing Azure SQL Data Warehouse
 
Introducing Azure Databases
Introducing Azure DatabasesIntroducing Azure Databases
Introducing Azure Databases
 
Statistis, Row Counts, Execution Plans and Query Tuning
Statistis, Row Counts, Execution Plans and Query TuningStatistis, Row Counts, Execution Plans and Query Tuning
Statistis, Row Counts, Execution Plans and Query Tuning
 
Understanding Your Servers, All Your Servers
Understanding Your Servers, All Your ServersUnderstanding Your Servers, All Your Servers
Understanding Your Servers, All Your Servers
 
Changing Your Habits: Tips to Tune Your T-SQL
Changing Your Habits: Tips to Tune Your T-SQLChanging Your Habits: Tips to Tune Your T-SQL
Changing Your Habits: Tips to Tune Your T-SQL
 
Azure SQL Database for the Earthed DBA
Azure SQL Database for the Earthed DBAAzure SQL Database for the Earthed DBA
Azure SQL Database for the Earthed DBA
 

Recently uploaded

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 

Recently uploaded (20)

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 

Using Query Store to Understand and Control Query Performance

  • 1. Using Query Store to Understand and Control Query Performance
  • 2. Goals • Learn the kinds of data that query store collects in support of knowledge about query performance • Understand the mechanisms of control that are offered to fine tune Query Store data collection • Comprehend the ability to take control of query behaviors through plan forcing and hints
  • 3. DevOps Advocate Microsoft Data Platform MVP AWS Community Builder @gfritchey grant@scarydba.com scarydba.com
  • 4. Query Store Functionality • Individual database setting • On by default in Azure SQL Database and SQL Server 2022 • Asynchronous data collection • First to memory • Then to disk • Basis of data is the query • A query has one or more plans • A query has runtime metrics • A query experiences waits • Data collected before and after query execution
  • 5. How Query Store Works: Before Execution T-SQL Query Query Optimizer Execution Plan Plan Cache Asynchronous Data Collection Query Store Memory Asynchronous Data Writes Query Store Data Query Execution
  • 6. How Query Store Works: After Execution Results Asynchronous Data Collection Query Store Memory Asynchronous Data Writes Query Store Data Query Execution
  • 7. Data Query Store Collects • Query • Including T-SQL text • No parameter values… but • Execution plan • Plan w/o runtime values (AKA “Estimated Plan”) • Runtime metrics • Aggregated • Multiple aggregates • Wait statistics • Aggregated • Multiple aggregates
  • 8. Data Is Stored in System Views • Sys.query_context_settings – information about the settings for the query, including things like ANSI settings • Sys.query_store_query – properties around the query such as hash, count of compiles, last compile duration, object_id & more • Sys.query_store_query_text – the T-SQL for the query itself • Sys.query_store_plan – execution plans and properties around them • Sys.query_store_runtime_stats_interval – the defined start & stop time of runtime data aggregations • Sys.query_store_runtime_stats – the aggregated information like average execution time, standard deviation, reads, writes, etc. • Sys.query_store_wait_stats – the aggregated wait statistics for the query & plan in question
  • 9. Controlling Query Store: Basics • Enable/Disable Query Store • Also READ ONLY • Data flush interval (default 15 minutes) • Max storage (varies per version) • Aggregation interval length (default 60 minutes) • Cleanup mechanisms (both days & size-based cleanup)
  • 10. Controlling Query Store: Data Collection • Defaults vary by version • Modes: • All – simple, all queries, probably not the safest approach • Auto – “capture queries based on resource consumption”, 3 executions or longer than 1 second • None – Query Store is enabled, but doesn’t capture new queries • Custom – 2019+ • EXECUTION_COUNT • TOTAL_COMPILE_CPU_TIME • TOTAL_EXECUTION_CPU_TIME_MS • STALE_CAPTURE_POLICY_THRESHOLD
  • 12. Plan Forcing • Forcing execution plans • T-SQL • GUI • Forcing query hints • T-SQL • Optimized plan forcing
  • 13. Demo
  • 14. Some Suggested Best Practices • Monitor data size closely • Data capture should be Auto or, better still, Custom • Enable TraceFlags 7752 (prior to 2019) and 7745 • Minimize your historical data • Regularly check Query Store status • Where possible, avoid non-parameterized queries • Use ALTER instead of DROP/CREATE where you can
  • 15. Why You Need Query Store • Performance data collection with unique data • Ability to force plans • As an aid to upgrades • Basis for most Intelligent Query Processing • Traditional query tuning and performance troubleshooting
  • 16. Additional Resources • Query Store for SQL Server 2019 – Tracy Boggiano, Grant Fritchey • dbaTools • SQL Server 2022 Query Performance Tuning – Grant Fritchey • Best Practices With Query Store – Erin Stellato • Best Practices With Query Store - Microsoft
  • 17. DevOps Advocate Microsoft Data Platform MVP AWS Community Builder @gfritchey grant@scarydba.com scarydba.com