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

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
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file systemNikhil Anurag VN
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic ConceptsTony Wong
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL CommandsShrija Madhu
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Punjab University
 
Sql clauses by Manan Pasricha
Sql clauses by Manan PasrichaSql clauses by Manan Pasricha
Sql clauses by Manan PasrichaMananPasricha
 
Automacao de Testes de Softwares
Automacao de Testes de SoftwaresAutomacao de Testes de Softwares
Automacao de Testes de SoftwaresEduardo Souza
 
Oracle architecture
Oracle architectureOracle architecture
Oracle architectureSoumya Das
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsCarlos Sierra
 
1. SQL Basics - Introduction
1. SQL Basics - Introduction1. SQL Basics - Introduction
1. SQL Basics - IntroductionVarun A M
 
Oracle architecture ppt
Oracle architecture pptOracle architecture ppt
Oracle architecture pptDeepak Shetty
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredDanish Mehraj
 

What's hot (20)

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
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file system
 
Oracle Database View
Oracle Database ViewOracle Database View
Oracle Database View
 
MS SQL Server
MS SQL ServerMS SQL Server
MS SQL Server
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
 
Sql clauses by Manan Pasricha
Sql clauses by Manan PasrichaSql clauses by Manan Pasricha
Sql clauses by Manan Pasricha
 
Automacao de Testes de Softwares
Automacao de Testes de SoftwaresAutomacao de Testes de Softwares
Automacao de Testes de Softwares
 
Troubleshooting sql server
Troubleshooting sql serverTroubleshooting sql server
Troubleshooting sql server
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
8. sql
8. sql8. sql
8. sql
 
Oracle architecture
Oracle architectureOracle architecture
Oracle architecture
 
PHP Regular Expressions
PHP Regular ExpressionsPHP Regular Expressions
PHP Regular Expressions
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 
1. SQL Basics - Introduction
1. SQL Basics - Introduction1. SQL Basics - Introduction
1. SQL Basics - Introduction
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
SQL
SQLSQL
SQL
 
Oracle architecture ppt
Oracle architecture pptOracle architecture ppt
Oracle architecture ppt
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
 

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
 
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 (16)

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

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
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
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Recently uploaded (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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?
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
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...
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

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)