Upload
ahsan-kabir
View
303
Download
1
Embed Size (px)
Citation preview
Q U E R Y S T O R E I N
S Q L S E R V E R 2 0 1 6
A TO U R O F N E W F E AT U R E S
Ahsan Kabir
MVP on Data Platform
“techforum” user group Meetup
WHAT
Query store has introduced in SQL Server 2016 for simplification of
performance troubleshooting process. Queries having multiple plans:
identify un-efficient plans and force a better plan.
Query store stores the insight information of queries i.e.
history of queries,
plans, and
runtime statistics,
resource usage patterns
database usage patterns
query plan and
regressing queries.
WHY• Explore the queries execution
• Resource consuming queries
• Figure out query plan
• Identify possible performance degradation queries
• Figure out why regressions happen
• Force the query processor to use a particular plan
• Query Store is accessible through Transact-SQL.
• Identify and improve ad-hoc workloads
• Pinpoint and fix queries
• Custom reporting and/or alerting through
Dynamic Management Views (DMVs)
HOWStep :1 Query Compilation
SQL Server compiles a query > Compile message >Store into Query Store with execution plan
Step :2 Execution Time
Query is execution > Execute message >Store into Query Store with run time statistics
Step :3 Post execution
After Execution >Query Store aggregates the information in Memory
>Aggregated data will be asynchronously store into primary file group
ConfigureQueryStore
QueryData Store
Let’s Find &
Tune
STEP’S
S te
p1: E
nab
le Q
uery
Sto
re
Management Studio
Management Studio >Object Explorer >Right-click a database>Properties >Set Enable =True
Transact-SQL Statements
“ALTER DATABASE AdventureWorks2016CTP3 SET QUERY_STORE = ON;”
Step 2
: Configu
ration u
sing
SSM
S Operation Mode :Available option Off, Read Write or Read. In Read mode no new Execution Plans or query runtime statistics will be collected.
Data Flush Interval (Minutes): being flushed from memory to disk.
Statistics Collection Interval:It set the aggregation interval of query runtime statistics inside the Query Store.Max Size (MB) indicate maximum size of Query Store.
Query Store Capture Mode All capture all queriesAuto Base on resources consumption.None stop capturing Size Based Cleanup Mode Activate data cleanup automatically when data reach at Max size.Off Data cleanup don’t take place
Auto Data cleanup happens automaticallyStale Query Threshold (Days) Sets how long query data is retained inside the Query Store. By default the setting is configured to 367 days.
Step 3
: C
onfigu
re u
sin
g T
-SQ
L
ALTER DATABASE AdventureWorks2016CTP3
SET QUERY_STORE = ON(OPERATION_MODE = READ_WRITE,
CLEANUP_POLICY = (STALE_QUERY_THRESHOLD_DAYS = 10),DATA_FLUSH_INTERVAL_SECONDS = 5000,MAX_STORAGE_SIZE_MB = 1000,INTERVAL_LENGTH_MINUTES = 10,SIZE_BASED_CLEANUP_MODE = AUTO,QUERY_CAPTURE_MODE = AUTO,MAX_PLANS_PER_QUERY = 500
);GO
Query
Sto
re c
onta
iner
in S
SM
S
SSMS view Scenario
Regressed
Queries
Pinpoint queries for which execution
metrics have recently regressed (i.e.
changed to worse).
Top Resource
Consuming
Queries
Queries which have the biggest impact to
database resource consumption.
Tracked Queries
when you have queries with forced plans
and you want to make sure that query
performance is stable.
Overall Resource
Consumption
Analyze the total resource consumption
for the database. Use this view to identify
resource patterns (daily vs. nightly
workloads) and optimize overall
consumption for your database.
Step 1
: Pin
poin
t an
d fix
Regressed Queries :
Object Explorer >Select Database >Query Store >Regressed Queries
T H A N K S
H AV E A N I C E D AY