SlideShare a Scribd company logo
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
Ad

More Related Content

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
Javier Villegas
 
SQLDay2013_MarcinSzeliga_StoredProcedures
SQLDay2013_MarcinSzeliga_StoredProceduresSQLDay2013_MarcinSzeliga_StoredProcedures
SQLDay2013_MarcinSzeliga_StoredProcedures
Polish SQL Server User Group
 
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
Remote DBA Experts
 
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdfpdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
cookie1969
 
Query optimization
Query optimizationQuery optimization
Query optimization
Zunera Bukhari
 
4. (mjk) extreme performance 2
4. (mjk) extreme performance 24. (mjk) extreme performance 2
4. (mjk) extreme performance 2
Doina 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 works
Hoang Nguyen
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Fraboni Ec
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
James Wong
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Harry Potter
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Tony Nguyen
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Luis Goldster
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Young Alista
 
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbeganKoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
Tobias 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 Tuning
OracleTrainings
 
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
Ivan Kosianenko
 
Performance tuning in sql server
Performance tuning in sql serverPerformance tuning in sql server
Performance tuning in sql server
Antonios Chatzipavlis
 
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
sqlserver.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 Analysis
DAGEOP LTD
 
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
Javier 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 Features
Remote DBA Experts
 
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdfpdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
cookie1969
 
4. (mjk) extreme performance 2
4. (mjk) extreme performance 24. (mjk) extreme performance 2
4. (mjk) extreme performance 2
Doina 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 works
Hoang Nguyen
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Fraboni Ec
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
James Wong
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Harry Potter
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Tony Nguyen
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Luis Goldster
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Young Alista
 
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbeganKoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
Tobias 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 Tuning
OracleTrainings
 
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
Ivan 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 1
sqlserver.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 Analysis
DAGEOP LTD
 

More from Grant Fritchey (20)

You Need a PostgreSQL Restore Plan Presentation
You Need a PostgreSQL Restore Plan PresentationYou Need a PostgreSQL Restore Plan Presentation
You Need a PostgreSQL Restore Plan Presentation
Grant Fritchey
 
PostgreSQL Query Performance Monitoring for the Absolute Beginner
PostgreSQL Query Performance Monitoring for the Absolute BeginnerPostgreSQL Query Performance Monitoring for the Absolute Beginner
PostgreSQL Query Performance Monitoring for the Absolute Beginner
Grant Fritchey
 
Leveraging AI for the PostgreSQL DBA #pgconf.eu
Leveraging AI for the PostgreSQL DBA #pgconf.euLeveraging AI for the PostgreSQL DBA #pgconf.eu
Leveraging AI for the PostgreSQL DBA #pgconf.eu
Grant Fritchey
 
Exploring Execution Plans, Learning to Read SQL Server Execution Plans
Exploring Execution Plans, Learning to Read SQL Server Execution PlansExploring Execution Plans, Learning to Read SQL Server Execution Plans
Exploring Execution Plans, Learning to Read SQL Server Execution Plans
Grant Fritchey
 
SQL Server Performance Tuning: Common Problems, Possible Solutions
SQL Server Performance Tuning: Common Problems, Possible SolutionsSQL Server Performance Tuning: Common Problems, Possible Solutions
SQL Server Performance Tuning: Common Problems, Possible Solutions
Grant Fritchey
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
Migrating To PostgreSQL
Migrating To PostgreSQLMigrating To PostgreSQL
Migrating To PostgreSQL
Grant Fritchey
 
PostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and AlertingPostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and Alerting
Grant Fritchey
 
Automating Database Deployments Using Azure DevOps
Automating Database Deployments Using Azure DevOpsAutomating Database Deployments Using Azure DevOps
Automating Database Deployments Using Azure DevOps
Grant 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.pdf
Grant 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 Session
Grant 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 Tuning
Grant Fritchey
 
10 Steps To Global Data Compliance
10 Steps To Global Data Compliance10 Steps To Global Data Compliance
10 Steps To Global Data Compliance
Grant Fritchey
 
Time to Use the Columnstore Index
Time to Use the Columnstore IndexTime to Use the Columnstore Index
Time to Use the Columnstore Index
Grant Fritchey
 
Introduction to SQL Server in Containers
Introduction to SQL Server in ContainersIntroduction to SQL Server in Containers
Introduction to SQL Server in Containers
Grant Fritchey
 
DevOps for the DBA
DevOps for the DBADevOps for the DBA
DevOps for the DBA
Grant 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 It
Grant 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 DevOps
Grant Fritchey
 
SQL Server Tools for Query Tuning
SQL Server Tools for Query TuningSQL Server Tools for Query Tuning
SQL Server Tools for Query Tuning
Grant Fritchey
 
Extending DevOps to SQL Server
Extending DevOps to SQL ServerExtending DevOps to SQL Server
Extending DevOps to SQL Server
Grant Fritchey
 
You Need a PostgreSQL Restore Plan Presentation
You Need a PostgreSQL Restore Plan PresentationYou Need a PostgreSQL Restore Plan Presentation
You Need a PostgreSQL Restore Plan Presentation
Grant Fritchey
 
PostgreSQL Query Performance Monitoring for the Absolute Beginner
PostgreSQL Query Performance Monitoring for the Absolute BeginnerPostgreSQL Query Performance Monitoring for the Absolute Beginner
PostgreSQL Query Performance Monitoring for the Absolute Beginner
Grant Fritchey
 
Leveraging AI for the PostgreSQL DBA #pgconf.eu
Leveraging AI for the PostgreSQL DBA #pgconf.euLeveraging AI for the PostgreSQL DBA #pgconf.eu
Leveraging AI for the PostgreSQL DBA #pgconf.eu
Grant Fritchey
 
Exploring Execution Plans, Learning to Read SQL Server Execution Plans
Exploring Execution Plans, Learning to Read SQL Server Execution PlansExploring Execution Plans, Learning to Read SQL Server Execution Plans
Exploring Execution Plans, Learning to Read SQL Server Execution Plans
Grant Fritchey
 
SQL Server Performance Tuning: Common Problems, Possible Solutions
SQL Server Performance Tuning: Common Problems, Possible SolutionsSQL Server Performance Tuning: Common Problems, Possible Solutions
SQL Server Performance Tuning: Common Problems, Possible Solutions
Grant Fritchey
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
Migrating To PostgreSQL
Migrating To PostgreSQLMigrating To PostgreSQL
Migrating To PostgreSQL
Grant Fritchey
 
PostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and AlertingPostgreSQL Performance Problems: Monitoring and Alerting
PostgreSQL Performance Problems: Monitoring and Alerting
Grant Fritchey
 
Automating Database Deployments Using Azure DevOps
Automating Database Deployments Using Azure DevOpsAutomating Database Deployments Using Azure DevOps
Automating Database Deployments Using Azure DevOps
Grant 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.pdf
Grant 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 Session
Grant 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 Tuning
Grant Fritchey
 
10 Steps To Global Data Compliance
10 Steps To Global Data Compliance10 Steps To Global Data Compliance
10 Steps To Global Data Compliance
Grant Fritchey
 
Time to Use the Columnstore Index
Time to Use the Columnstore IndexTime to Use the Columnstore Index
Time to Use the Columnstore Index
Grant Fritchey
 
Introduction to SQL Server in Containers
Introduction to SQL Server in ContainersIntroduction to SQL Server in Containers
Introduction to SQL Server in Containers
Grant 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 It
Grant 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 DevOps
Grant Fritchey
 
SQL Server Tools for Query Tuning
SQL Server Tools for Query TuningSQL Server Tools for Query Tuning
SQL Server Tools for Query Tuning
Grant Fritchey
 
Extending DevOps to SQL Server
Extending DevOps to SQL ServerExtending DevOps to SQL Server
Extending DevOps to SQL Server
Grant Fritchey
 
Ad

Recently uploaded (20)

Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdfProtect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
株式会社クライム
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509
Fermin Galan
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Time Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project TechniquesTime Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project Techniques
Livetecs LLC
 
Wilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For WindowsWilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For Windows
Google
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
How to avoid IT Asset Management mistakes during implementation_PDF.pdf
How to avoid IT Asset Management mistakes during implementation_PDF.pdfHow to avoid IT Asset Management mistakes during implementation_PDF.pdf
How to avoid IT Asset Management mistakes during implementation_PDF.pdf
victordsane
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
Tools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google CertificateTools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google Certificate
VICTOR MAESTRE RAMIREZ
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdfProtect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
Protect HPE VM Essentials using Veeam Agents-a50012338enw.pdf
株式会社クライム
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
Sequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptxSequence Diagrams With Pictures (1).pptx
Sequence Diagrams With Pictures (1).pptx
aashrithakondapalli8
 
Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509Orion Context Broker introduction 20250509
Orion Context Broker introduction 20250509
Fermin Galan
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025Wilcom Embroidery Studio Crack Free Latest 2025
Wilcom Embroidery Studio Crack Free Latest 2025
Web Designer
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Time Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project TechniquesTime Estimation: Expert Tips & Proven Project Techniques
Time Estimation: Expert Tips & Proven Project Techniques
Livetecs LLC
 
Wilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For WindowsWilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For Windows
Google
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
How to avoid IT Asset Management mistakes during implementation_PDF.pdf
How to avoid IT Asset Management mistakes during implementation_PDF.pdfHow to avoid IT Asset Management mistakes during implementation_PDF.pdf
How to avoid IT Asset Management mistakes during implementation_PDF.pdf
victordsane
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
Tools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google CertificateTools of the Trade: Linux and SQL - Google Certificate
Tools of the Trade: Linux and SQL - Google Certificate
VICTOR MAESTRE RAMIREZ
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Ad

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
  翻译: