SlideShare a Scribd company logo
1 of 26
SQL Server Query Store
Vitaliy Popovych
About me
• Vitaliy Popovych
• Database Developer at Intapp
Agenda
• Query Store
• How it works
• Configuration Options
• UI Management Studio
• Query Store Catalog Views
• Query Store Stored Procedures
• Best Practice with the Query Store
• Demo
Recompiling Execution Plans
• Changes made to a table or view referenced by the query (ALTER TABLE and
ALTER VIEW).
• Changes made to a single procedure, which would drop all plans for that
procedure from the cache (ALTER PROCEDURE).
• Changes to any indexes used by the execution plan.
• Updates on statistics used by the execution plan, generated either explicitly
from a statement, such as UPDATE STATISTICS, or generated automatically.
• Dropping an index used by the execution plan.
• An explicit call to sp_recompile.
• Large numbers of changes to keys (generated by INSERT or DELETE
statements from other users that modify a table referenced by the query).
• For tables with triggers, if the number of rows in
the inserted or deleted tables grows significantly.
• Executing a stored procedure using the WITH RECOMPILE option.
What is Query Store?
Query Store
Compile
Execute
Plan Store
Runtime Stats
Query Store
Schema
How to start
Common scenarios
• Quickly find and fix a plan performance regression by forcing the previous
query plan. Fix queries that have recently regressed in performance due to
execution plan changes.
• Determine the number of times a query was executed in a given time
window, assisting a DBA in troubleshooting performance resource
problems.
• Identify top n queries (by execution time, memory consumption, etc.) in
the past x hours.
• Audit the history of query plans for a given query.
• Analyze the resource (CPU, I/O, and Memory) usage patterns for a
particular database.
Enable Query Store
By Using Transact-SQL Statements
ALTER DATABASE [AdventureWorks2016CTP3]
SET QUERY_STORE = ON
(
CLEANUP_POLICY = (STALE_QUERY_THRESHOLD_DAYS = 31),
DATA_FLUSH_INTERVAL_SECONDS = 900,
INTERVAL_LENGTH_MINUTES = 5,
MAX_STORAGE_SIZE_MB = 1024,
QUERY_CAPTURE_MODE = ALL,
SIZE_BASED_CLEANUP_MODE = AUTO
)
GO
By Using the Query Store Page in Management Studio
- In the Database Properties dialog box, select the Query Store page.
- In the Enable box, select True.
Configuration Options
 OPERATION_MODE
 CLEANUP_POLICY
 DATA_FLUSH_INTERVAL_SECONDS
 MAX_STORAGE_SIZE_MB
 INTERVAL_LENGTH_MINUTES
 SIZE_BASED_CLEANUP_MODE
 MAX_PLANS_PER_QUERY
Configuration Options
MAX_STORAGE_SIZE_MB (Configures the maximum size of the
query store. If the data in the query store hits the
MAX_STORAGE_SIZE_MB limit, the query store automatically
changes the state from read-write to read-only and stops
collecting new data) default value = 100 MB
OPERATION_MODE (Can be READ_WRITE or READ_ONLY)
default value = READ_WRITE
CLEANUP_POLICY (Configure the
STALE_QUERY_THRESHOLD_DAYS argument to specify the
number of days to retain data in the query store)
default value = 367 days
Configuration Options
DATA_FLUSH_INTERVAL_SECONDS (Determines the frequency
at which data written to the query store is persisted to disk. To
optimize for performance, data collected by the query store is
asynchronously written to the disk. The frequency at which this
asynchronous transfer occurs is configured via
DATA_FLUSH_INTERVAL_SECONDS) default value = 900 sec
INTERVAL_LENGTH_MINUTES (Determines the time interval at
which runtime execution statistics data is aggregated into the
query store. To optimize for space usage, the runtime
execution statistics in the Runtime Stats Store are aggregated
over a fixed time window. This fixed time window is configured
via INTERVAL_LENGTH_MINUTES) default value = 60 min
Configuration Options
QUERY_CAPTURE_MODE (Designates if the Query Store
captures all queries, or relevant queries based on execution
count and resource consumption, or stops adding new queries
and just tracks current queries) default value = all
MAX_PLANS_PER_QUERY (An integer representing the
maximum number of plans maintained for each query)
default value = 200
SIZE_BASED_CLEANUP_MODE (Controls whether the cleanup
process will be automatically activated when total amount of
data gets close to maximum size)
default value = OFF
Information
Execution metric Statistic function
CPU time,
Duration,
Execution Count,
Logical Reads,
Logical writes,
Memory consumption,
Physical Reads
Average,
Maximum,
Minimum,
Standard Deviation,
Total
UI Management Studio
Regressed Queries (Pinpoint queries
for which execution metrics have recently
regressed i.e. changed to worse)
Overall Resource Consumption
(Analyze the total resource consumption
for the database for any of the execution
metrics)
Top Resource Consuming Queries
(Queries which have the biggest impact to
database resource consumption)
Tracked Queries (Track the execution of
the most important queries in real-time)
Regressed Queries
Pinpoint queries for which execution metrics have recently regressed (i.e. changed to
worse). Use this view to correlate observed performance problems in your application
with the actual queries that needs to be fixed or improved.
Overall Resource Consumption
Analyze the total resource consumption for the database for any of the execution
metrics. Use this view to identify resource patterns (daily vs. nightly workloads) and
optimize overall consumption for your database.
Top Resource Consuming Queries
Choose an execution metric of interest and identify queries that had the most extreme
values for a provided time interval. Use this view to focus your attention on the most
relevant queries which have the biggest impact to database resource consumption.
Tracked Queries
Track the execution of the most important queries in real-time. Typically, you use this
view when you have queries with forced plans and you want to make sure that query
performance is stable.
Query Store Catalog Views
• sys.database_query_store_options (Returns the Query Store
options for this database)
• sys.query_store_plan (Contains information about each execution plan
associated with a query)
• sys.query_store_query (Contains information about the query and
aggregated runtime execution statistics)
• sys.query_store_query_text (Contains the Transact-SQL text and
the SQL handle of the query)
• sys.query_store_runtime_stats (Contains information about the
runtime execution statistics information for the query)
• sys.query_store_runtime_stats_interval (Contains
information about the start and end)
Query Store Stored Procedures
• sp_query_store_flush_db (Flushes the in-memory portion of the
Query Store data to disk)
• sp_query_store_force_plan (Enables forcing a particular plan for a
particular query)
• sp_query_store_remove_plan (Removes a single plan from the
query store)
• sp_query_store_remove_query (Removes the query, as well as
all associated plans and runtime stats from the query store)
• sp_query_store_reset_exec_stats (Clears the runtime stats for
a specific query plan from the query store)
• sp_query_store_unforce_plan (Enables unforcing a particular
plan for a particular query)
Best Practice with the Query Store
• Use the Latest SQL Server Management Studio
• Keep Query Store Adjusted to your Workload
• Verify Query Store is Collecting Query Data
Continuously
• Set the Optimal Query Capture Mode
• Keep the Most Relevant Data in Query Store
• Avoid Using Non-Parameterized Queries
• Check the Status of Forced Plans Regularly
Demo
Resources
• SQLServer Blog
• MSDN
• A flight data recorder for your database (Borko Novakovic)
• The SQL Server Query Store (Benjamin Nevarez)
Question?
Thanks!
Vitaliy Popovych
E-mail: vitaliy.popovych@outlook.com

More Related Content

What's hot

Skillshare - Introduction to Data Scraping
Skillshare - Introduction to Data ScrapingSkillshare - Introduction to Data Scraping
Skillshare - Introduction to Data ScrapingSchool of Data
 
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...DataStax
 
Natural Language processing
Natural Language processingNatural Language processing
Natural Language processingSanzid Kawsar
 
Data Federation with Apache Spark
Data Federation with Apache SparkData Federation with Apache Spark
Data Federation with Apache SparkDataWorks Summit
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data ScienceANOOP V S
 
Use of data science in recommendation system
Use of data science in  recommendation systemUse of data science in  recommendation system
Use of data science in recommendation systemAkashPatil334
 
DataMinds 2022 Azure Purview Erwin de Kreuk
DataMinds 2022 Azure Purview Erwin de KreukDataMinds 2022 Azure Purview Erwin de Kreuk
DataMinds 2022 Azure Purview Erwin de KreukErwin de Kreuk
 
How to boost your datamanagement with Dremio ?
How to boost your datamanagement with Dremio ?How to boost your datamanagement with Dremio ?
How to boost your datamanagement with Dremio ?Vincent Terrasi
 
Fractal Tree Indexes : From Theory to Practice
Fractal Tree Indexes : From Theory to PracticeFractal Tree Indexes : From Theory to Practice
Fractal Tree Indexes : From Theory to PracticeTim Callaghan
 
Building a Knowledge Graph with Spark and NLP: How We Recommend Novel Drugs t...
Building a Knowledge Graph with Spark and NLP: How We Recommend Novel Drugs t...Building a Knowledge Graph with Spark and NLP: How We Recommend Novel Drugs t...
Building a Knowledge Graph with Spark and NLP: How We Recommend Novel Drugs t...Databricks
 
DBT ELT approach for Advanced Analytics.pptx
DBT ELT approach for Advanced Analytics.pptxDBT ELT approach for Advanced Analytics.pptx
DBT ELT approach for Advanced Analytics.pptxHong Ong
 
Scaling massive elastic search clusters - Rafał Kuć - Sematext
Scaling massive elastic search clusters - Rafał Kuć - SematextScaling massive elastic search clusters - Rafał Kuć - Sematext
Scaling massive elastic search clusters - Rafał Kuć - SematextRafał Kuć
 
Slash n near real time indexing
Slash n   near real time indexingSlash n   near real time indexing
Slash n near real time indexingUmesh Prasad
 

What's hot (20)

Skillshare - Introduction to Data Scraping
Skillshare - Introduction to Data ScrapingSkillshare - Introduction to Data Scraping
Skillshare - Introduction to Data Scraping
 
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
Lessons Learned From Running 1800 Clusters (Brooke Jensen, Instaclustr) | Cas...
 
Natural Language processing
Natural Language processingNatural Language processing
Natural Language processing
 
Data Federation with Apache Spark
Data Federation with Apache SparkData Federation with Apache Spark
Data Federation with Apache Spark
 
ML Playbook
ML PlaybookML Playbook
ML Playbook
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Use of data science in recommendation system
Use of data science in  recommendation systemUse of data science in  recommendation system
Use of data science in recommendation system
 
DataMinds 2022 Azure Purview Erwin de Kreuk
DataMinds 2022 Azure Purview Erwin de KreukDataMinds 2022 Azure Purview Erwin de Kreuk
DataMinds 2022 Azure Purview Erwin de Kreuk
 
web mining
web miningweb mining
web mining
 
Database concepts
Database conceptsDatabase concepts
Database concepts
 
How to boost your datamanagement with Dremio ?
How to boost your datamanagement with Dremio ?How to boost your datamanagement with Dremio ?
How to boost your datamanagement with Dremio ?
 
Fractal Tree Indexes : From Theory to Practice
Fractal Tree Indexes : From Theory to PracticeFractal Tree Indexes : From Theory to Practice
Fractal Tree Indexes : From Theory to Practice
 
Building a Knowledge Graph with Spark and NLP: How We Recommend Novel Drugs t...
Building a Knowledge Graph with Spark and NLP: How We Recommend Novel Drugs t...Building a Knowledge Graph with Spark and NLP: How We Recommend Novel Drugs t...
Building a Knowledge Graph with Spark and NLP: How We Recommend Novel Drugs t...
 
Dremio introduction
Dremio introductionDremio introduction
Dremio introduction
 
DBT ELT approach for Advanced Analytics.pptx
DBT ELT approach for Advanced Analytics.pptxDBT ELT approach for Advanced Analytics.pptx
DBT ELT approach for Advanced Analytics.pptx
 
Postgresql
PostgresqlPostgresql
Postgresql
 
Introduction to Data Mining
Introduction to Data MiningIntroduction to Data Mining
Introduction to Data Mining
 
Scaling massive elastic search clusters - Rafał Kuć - Sematext
Scaling massive elastic search clusters - Rafał Kuć - SematextScaling massive elastic search clusters - Rafał Kuć - Sematext
Scaling massive elastic search clusters - Rafał Kuć - Sematext
 
Slash n near real time indexing
Slash n   near real time indexingSlash n   near real time indexing
Slash n near real time indexing
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 

Viewers also liked

Performance Monitoring And Tuning In Sql Server 2008 Tsql
Performance Monitoring And Tuning In Sql Server 2008 TsqlPerformance Monitoring And Tuning In Sql Server 2008 Tsql
Performance Monitoring And Tuning In Sql Server 2008 Tsqlcoolajju143
 
Паралельний імпорт: економіко-правові аспекти регулювання
Паралельний імпорт: економіко-правові аспекти регулюванняПаралельний імпорт: економіко-правові аспекти регулювання
Паралельний імпорт: економіко-правові аспекти регулюванняnadeh
 
What is in it for a dba sql server 2012
What is in it for a dba   sql server 2012What is in it for a dba   sql server 2012
What is in it for a dba sql server 2012Deepthi Anantharam
 
Gamma Soft. L'entreprise Temps-Réel
Gamma Soft. L'entreprise Temps-RéelGamma Soft. L'entreprise Temps-Réel
Gamma Soft. L'entreprise Temps-RéelGamma Soft
 
Sql Server 2016 Always Encrypted
Sql Server 2016 Always EncryptedSql Server 2016 Always Encrypted
Sql Server 2016 Always EncryptedDuncan Greaves PhD
 
SQL Server 2016 - Stretch DB
SQL Server 2016 - Stretch DB SQL Server 2016 - Stretch DB
SQL Server 2016 - Stretch DB Shy Engelberg
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerKevin Kline
 
Always encrypted overview
Always encrypted overviewAlways encrypted overview
Always encrypted overviewSolidQ
 
Stretch Database
Stretch DatabaseStretch Database
Stretch DatabaseSolidQ
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance TuningBala Subra
 
SQL Server - Using Tools to Analyze Query Performance
SQL Server - Using Tools to Analyze Query PerformanceSQL Server - Using Tools to Analyze Query Performance
SQL Server - Using Tools to Analyze Query PerformanceMarek Maśko
 
SQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML DataSQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML DataMarek Maśko
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshootingNathan Winters
 
SQL Saturday 510 Paris 2016 - Query Store session - final
SQL Saturday 510 Paris 2016 - Query Store session - finalSQL Saturday 510 Paris 2016 - Query Store session - final
SQL Saturday 510 Paris 2016 - Query Store session - finalPhilippe Geiger
 
MS Sql Server: Advanced Query Concepts
MS Sql Server: Advanced Query ConceptsMS Sql Server: Advanced Query Concepts
MS Sql Server: Advanced Query ConceptsDataminingTools Inc
 

Viewers also liked (18)

Performance Monitoring And Tuning In Sql Server 2008 Tsql
Performance Monitoring And Tuning In Sql Server 2008 TsqlPerformance Monitoring And Tuning In Sql Server 2008 Tsql
Performance Monitoring And Tuning In Sql Server 2008 Tsql
 
Паралельний імпорт: економіко-правові аспекти регулювання
Паралельний імпорт: економіко-правові аспекти регулюванняПаралельний імпорт: економіко-правові аспекти регулювання
Паралельний імпорт: економіко-правові аспекти регулювання
 
What is in it for a dba sql server 2012
What is in it for a dba   sql server 2012What is in it for a dba   sql server 2012
What is in it for a dba sql server 2012
 
Gamma Soft. L'entreprise Temps-Réel
Gamma Soft. L'entreprise Temps-RéelGamma Soft. L'entreprise Temps-Réel
Gamma Soft. L'entreprise Temps-Réel
 
Sql Server 2016 Always Encrypted
Sql Server 2016 Always EncryptedSql Server 2016 Always Encrypted
Sql Server 2016 Always Encrypted
 
SQL Server 2016 - Stretch DB
SQL Server 2016 - Stretch DB SQL Server 2016 - Stretch DB
SQL Server 2016 - Stretch DB
 
Troubleshooting sql server
Troubleshooting sql serverTroubleshooting sql server
Troubleshooting sql server
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL Server
 
Data juice
Data juiceData juice
Data juice
 
Always encrypted overview
Always encrypted overviewAlways encrypted overview
Always encrypted overview
 
Stretch Database
Stretch DatabaseStretch Database
Stretch Database
 
Sql Server Performance Tuning
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
 
SQL Server - Using Tools to Analyze Query Performance
SQL Server - Using Tools to Analyze Query PerformanceSQL Server - Using Tools to Analyze Query Performance
SQL Server - Using Tools to Analyze Query Performance
 
SQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML DataSQL Server - Querying and Managing XML Data
SQL Server - Querying and Managing XML Data
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshooting
 
SQL Saturday 510 Paris 2016 - Query Store session - final
SQL Saturday 510 Paris 2016 - Query Store session - finalSQL Saturday 510 Paris 2016 - Query Store session - final
SQL Saturday 510 Paris 2016 - Query Store session - final
 
Sql server basics
Sql server basicsSql server basics
Sql server basics
 
MS Sql Server: Advanced Query Concepts
MS Sql Server: Advanced Query ConceptsMS Sql Server: Advanced Query Concepts
MS Sql Server: Advanced Query Concepts
 

Similar to SQL Server 2016 Query store

Sql server 2016 rc 3 query store overview and architecture
Sql server 2016 rc 3  query store overview and architectureSql server 2016 rc 3  query store overview and architecture
Sql server 2016 rc 3 query store overview and architectureAhsan Kabir
 
Using Query Store to Understand and Control Query Performance
Using Query Store to Understand and Control Query PerformanceUsing Query Store to Understand and Control Query Performance
Using Query Store to Understand and Control Query PerformanceGrant Fritchey
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptxKareemBullard1
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basicsnitin anjankar
 
Live Query Statistics & Query Store in SQL Server 2016
Live Query Statistics & Query Store in SQL Server 2016Live Query Statistics & Query Store in SQL Server 2016
Live Query Statistics & Query Store in SQL Server 2016Antonios Chatzipavlis
 
Geek Sync | Intro to Query Store
Geek Sync | Intro to Query StoreGeek Sync | Intro to Query Store
Geek Sync | Intro to Query StoreIDERA Software
 
Part2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer StatisticsPart2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer StatisticsMaria Colgan
 
SQL 2016 Query Store: Et si mes queries m'étaient contées...
SQL 2016 Query Store: Et si mes queries m'étaient contées...SQL 2016 Query Store: Et si mes queries m'étaient contées...
SQL 2016 Query Store: Et si mes queries m'étaient contées...Isabelle Van Campenhoudt
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cRonald Francisco Vargas Quesada
 
Informix partitioning interval_rolling_window_table
Informix partitioning interval_rolling_window_tableInformix partitioning interval_rolling_window_table
Informix partitioning interval_rolling_window_tableKeshav Murthy
 
MemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks WebcastMemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks WebcastSingleStore
 
Query Store and live Query Statistics
Query Store and live Query StatisticsQuery Store and live Query Statistics
Query Store and live Query StatisticsSolidQ
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuningOutsourceAX
 
Oracle EBS Production Support - Recommendations
Oracle EBS Production Support - RecommendationsOracle EBS Production Support - Recommendations
Oracle EBS Production Support - RecommendationsVigilant Technologies
 
Business Insight 2014 - Microsofts nye BI og database platform - Erling Skaal...
Business Insight 2014 - Microsofts nye BI og database platform - Erling Skaal...Business Insight 2014 - Microsofts nye BI og database platform - Erling Skaal...
Business Insight 2014 - Microsofts nye BI og database platform - Erling Skaal...Microsoft
 
PostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_CheatsheetPostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_CheatsheetLucian Oprea
 
Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsfMao Geng
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuningYogiji Creations
 

Similar to SQL Server 2016 Query store (20)

Sql server 2016 rc 3 query store overview and architecture
Sql server 2016 rc 3  query store overview and architectureSql server 2016 rc 3  query store overview and architecture
Sql server 2016 rc 3 query store overview and architecture
 
Using Query Store to Understand and Control Query Performance
Using Query Store to Understand and Control Query PerformanceUsing Query Store to Understand and Control Query Performance
Using Query Store to Understand and Control Query Performance
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 
SQLDay2013_MarcinSzeliga_StoredProcedures
SQLDay2013_MarcinSzeliga_StoredProceduresSQLDay2013_MarcinSzeliga_StoredProcedures
SQLDay2013_MarcinSzeliga_StoredProcedures
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basics
 
Live Query Statistics & Query Store in SQL Server 2016
Live Query Statistics & Query Store in SQL Server 2016Live Query Statistics & Query Store in SQL Server 2016
Live Query Statistics & Query Store in SQL Server 2016
 
Geek Sync | Intro to Query Store
Geek Sync | Intro to Query StoreGeek Sync | Intro to Query Store
Geek Sync | Intro to Query Store
 
Part2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer StatisticsPart2 Best Practices for Managing Optimizer Statistics
Part2 Best Practices for Managing Optimizer Statistics
 
SQL 2016 Query Store: Et si mes queries m'étaient contées...
SQL 2016 Query Store: Et si mes queries m'étaient contées...SQL 2016 Query Store: Et si mes queries m'étaient contées...
SQL 2016 Query Store: Et si mes queries m'étaient contées...
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
 
Informix partitioning interval_rolling_window_table
Informix partitioning interval_rolling_window_tableInformix partitioning interval_rolling_window_table
Informix partitioning interval_rolling_window_table
 
MemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks WebcastMemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks Webcast
 
Query Store and live Query Statistics
Query Store and live Query StatisticsQuery Store and live Query Statistics
Query Store and live Query Statistics
 
Performance Tuning
Performance TuningPerformance Tuning
Performance Tuning
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuning
 
Oracle EBS Production Support - Recommendations
Oracle EBS Production Support - RecommendationsOracle EBS Production Support - Recommendations
Oracle EBS Production Support - Recommendations
 
Business Insight 2014 - Microsofts nye BI og database platform - Erling Skaal...
Business Insight 2014 - Microsofts nye BI og database platform - Erling Skaal...Business Insight 2014 - Microsofts nye BI og database platform - Erling Skaal...
Business Insight 2014 - Microsofts nye BI og database platform - Erling Skaal...
 
PostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_CheatsheetPostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_Cheatsheet
 
Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsf
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuning
 

Recently uploaded

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

SQL Server 2016 Query store

  • 1. SQL Server Query Store Vitaliy Popovych
  • 2. About me • Vitaliy Popovych • Database Developer at Intapp
  • 3. Agenda • Query Store • How it works • Configuration Options • UI Management Studio • Query Store Catalog Views • Query Store Stored Procedures • Best Practice with the Query Store • Demo
  • 4. Recompiling Execution Plans • Changes made to a table or view referenced by the query (ALTER TABLE and ALTER VIEW). • Changes made to a single procedure, which would drop all plans for that procedure from the cache (ALTER PROCEDURE). • Changes to any indexes used by the execution plan. • Updates on statistics used by the execution plan, generated either explicitly from a statement, such as UPDATE STATISTICS, or generated automatically. • Dropping an index used by the execution plan. • An explicit call to sp_recompile. • Large numbers of changes to keys (generated by INSERT or DELETE statements from other users that modify a table referenced by the query). • For tables with triggers, if the number of rows in the inserted or deleted tables grows significantly. • Executing a stored procedure using the WITH RECOMPILE option.
  • 5. What is Query Store?
  • 8. Common scenarios • Quickly find and fix a plan performance regression by forcing the previous query plan. Fix queries that have recently regressed in performance due to execution plan changes. • Determine the number of times a query was executed in a given time window, assisting a DBA in troubleshooting performance resource problems. • Identify top n queries (by execution time, memory consumption, etc.) in the past x hours. • Audit the history of query plans for a given query. • Analyze the resource (CPU, I/O, and Memory) usage patterns for a particular database.
  • 9. Enable Query Store By Using Transact-SQL Statements ALTER DATABASE [AdventureWorks2016CTP3] SET QUERY_STORE = ON ( CLEANUP_POLICY = (STALE_QUERY_THRESHOLD_DAYS = 31), DATA_FLUSH_INTERVAL_SECONDS = 900, INTERVAL_LENGTH_MINUTES = 5, MAX_STORAGE_SIZE_MB = 1024, QUERY_CAPTURE_MODE = ALL, SIZE_BASED_CLEANUP_MODE = AUTO ) GO By Using the Query Store Page in Management Studio - In the Database Properties dialog box, select the Query Store page. - In the Enable box, select True.
  • 10. Configuration Options  OPERATION_MODE  CLEANUP_POLICY  DATA_FLUSH_INTERVAL_SECONDS  MAX_STORAGE_SIZE_MB  INTERVAL_LENGTH_MINUTES  SIZE_BASED_CLEANUP_MODE  MAX_PLANS_PER_QUERY
  • 11. Configuration Options MAX_STORAGE_SIZE_MB (Configures the maximum size of the query store. If the data in the query store hits the MAX_STORAGE_SIZE_MB limit, the query store automatically changes the state from read-write to read-only and stops collecting new data) default value = 100 MB OPERATION_MODE (Can be READ_WRITE or READ_ONLY) default value = READ_WRITE CLEANUP_POLICY (Configure the STALE_QUERY_THRESHOLD_DAYS argument to specify the number of days to retain data in the query store) default value = 367 days
  • 12. Configuration Options DATA_FLUSH_INTERVAL_SECONDS (Determines the frequency at which data written to the query store is persisted to disk. To optimize for performance, data collected by the query store is asynchronously written to the disk. The frequency at which this asynchronous transfer occurs is configured via DATA_FLUSH_INTERVAL_SECONDS) default value = 900 sec INTERVAL_LENGTH_MINUTES (Determines the time interval at which runtime execution statistics data is aggregated into the query store. To optimize for space usage, the runtime execution statistics in the Runtime Stats Store are aggregated over a fixed time window. This fixed time window is configured via INTERVAL_LENGTH_MINUTES) default value = 60 min
  • 13. Configuration Options QUERY_CAPTURE_MODE (Designates if the Query Store captures all queries, or relevant queries based on execution count and resource consumption, or stops adding new queries and just tracks current queries) default value = all MAX_PLANS_PER_QUERY (An integer representing the maximum number of plans maintained for each query) default value = 200 SIZE_BASED_CLEANUP_MODE (Controls whether the cleanup process will be automatically activated when total amount of data gets close to maximum size) default value = OFF
  • 14. Information Execution metric Statistic function CPU time, Duration, Execution Count, Logical Reads, Logical writes, Memory consumption, Physical Reads Average, Maximum, Minimum, Standard Deviation, Total
  • 15. UI Management Studio Regressed Queries (Pinpoint queries for which execution metrics have recently regressed i.e. changed to worse) Overall Resource Consumption (Analyze the total resource consumption for the database for any of the execution metrics) Top Resource Consuming Queries (Queries which have the biggest impact to database resource consumption) Tracked Queries (Track the execution of the most important queries in real-time)
  • 16. Regressed Queries Pinpoint queries for which execution metrics have recently regressed (i.e. changed to worse). Use this view to correlate observed performance problems in your application with the actual queries that needs to be fixed or improved.
  • 17. Overall Resource Consumption Analyze the total resource consumption for the database for any of the execution metrics. Use this view to identify resource patterns (daily vs. nightly workloads) and optimize overall consumption for your database.
  • 18. Top Resource Consuming Queries Choose an execution metric of interest and identify queries that had the most extreme values for a provided time interval. Use this view to focus your attention on the most relevant queries which have the biggest impact to database resource consumption.
  • 19. Tracked Queries Track the execution of the most important queries in real-time. Typically, you use this view when you have queries with forced plans and you want to make sure that query performance is stable.
  • 20. Query Store Catalog Views • sys.database_query_store_options (Returns the Query Store options for this database) • sys.query_store_plan (Contains information about each execution plan associated with a query) • sys.query_store_query (Contains information about the query and aggregated runtime execution statistics) • sys.query_store_query_text (Contains the Transact-SQL text and the SQL handle of the query) • sys.query_store_runtime_stats (Contains information about the runtime execution statistics information for the query) • sys.query_store_runtime_stats_interval (Contains information about the start and end)
  • 21. Query Store Stored Procedures • sp_query_store_flush_db (Flushes the in-memory portion of the Query Store data to disk) • sp_query_store_force_plan (Enables forcing a particular plan for a particular query) • sp_query_store_remove_plan (Removes a single plan from the query store) • sp_query_store_remove_query (Removes the query, as well as all associated plans and runtime stats from the query store) • sp_query_store_reset_exec_stats (Clears the runtime stats for a specific query plan from the query store) • sp_query_store_unforce_plan (Enables unforcing a particular plan for a particular query)
  • 22. Best Practice with the Query Store • Use the Latest SQL Server Management Studio • Keep Query Store Adjusted to your Workload • Verify Query Store is Collecting Query Data Continuously • Set the Optimal Query Capture Mode • Keep the Most Relevant Data in Query Store • Avoid Using Non-Parameterized Queries • Check the Status of Forced Plans Regularly
  • 23. Demo
  • 24. Resources • SQLServer Blog • MSDN • A flight data recorder for your database (Borko Novakovic) • The SQL Server Query Store (Benjamin Nevarez)