• No results found

SQL Server 2016 Query Store

N/A
N/A
Protected

Academic year: 2021

Share "SQL Server 2016 Query Store"

Copied!
25
0
0

Loading.... (view fulltext now)

Full text

(1)

#SQLSAT454

SQL Server 2016 Query Store

Sergio Govoni

@segovoni

(2)

#SQLSAT454

(3)

#SQLSAT454

Speaker BIO

@segovoni SQL Server MVP ugiss.org segovoni@gmail.com sqlblog.com/blogs/sergio_govoni manning.com/delaney

(4)

#SQLSAT454

Agenda

 Query plan change

 Can cause performance issues

 Why do plan changes happen?

 Problems you face for slow running queries

 What does the Query Store do for you?

(5)

#SQLSAT454

QP changes can cause performance issues

• Database is not working • How to fix it ASAP?

Web site is

down

• Impossible to predict the root cause

Temporary

perf. issues

• Performance regression caused by the new version

SQL Server

upgrade

(6)

#SQLSAT454

Fixing query plan regression is hard

 Problems you face for slow running queries

 Time of the day and compiled parameters

 Has the Data Collector been activated?

 Plan cache may not be suitable for troubleshooting

 You have to find out why it is show

 When you have the issue on you hands

 Can you modify the query text?

(7)

#SQLSAT454

Let’s do a quiz

 Who is the author of this painting?

A. Pablo Picasso

B. Vincent Van Gogh C. Claude Monet D. Pierre-Auguste Renoir E. Query Optimizer  P1 P2 P3 P4

(8)

#SQLSAT454

Why do plan changes happen?

 Query Optimizer

generates and evaluates many plans for the same query

 Data changes every hour, so the QO might select a different plan

 Generally, boundary plans have the same

(9)

#SQLSAT454

What does the Query Store do for you?

 It stores all the plan choices and related performance metrics for each query

 It identifies queries that have become slower recently

 It allows DBA to force an execution plan easily  It makes sure your changes work across server

restart, upgrades, failover and query recompiles

(10)

#SQLSAT454

(11)

#SQLSAT454

How the Query Store exposes data

sys.query_store_runtime_stats

On-Disk Data In-Memory

Data

 Each DMV joined In-Memory and On-Disk data

 When memory pressure occurs, some data

In-Memory will be flushed to the disk

(12)

#SQLSAT454

How the Query Store interprets the query text

 Query text starts from the first character of the first token (of the statement) and it ends at the last character of the last token

 Comments and spaces, before or after, don’t

change anything

 Comments and spaces inside count

 sys.query_store_query_text

 query_text_id is used to force a plan for a query

 statement_sql_handle contains the MD5 hash of the query text

(13)

#SQLSAT454

Query Store DMV overview

Query_Text Query_ANSI Query_Plan Runtime_Stats

1:N 1:N 1:N

Context_Settings Runtime_Stats_Interval ANSI

Options

Execution plans Metrics: 1 row per plan per time interval

One row per unique combination of set options

One row per time interval

(14)

#SQLSAT454

Demo Environment

 A console application executes this query in a loop on a database where Query Store is

enabled

 Parameters are generated by a randomized function, values are between Zero and 100

 Plan cache is cleaned when parameters values are less than 2

(15)

#SQLSAT454

DEMO

(16)

#SQLSAT454

Query Store Tuning

 Because collecting data has always a cost, SQL Server allows you to tune the Query

Store with these options of ALTER DATABASE

statement

 INTERVAL_LENGTH_MINUTES

 MAX_STORAGE_SIZE_MB

 MAX_PLANS_PER_QUERY (200 by default)

 QUERY_CAPTURE_MODE (ALL, AUTO, NONE)

(17)

#SQLSAT454

Server Upgrades

 Are you worried about SQL Server upgrades? This is the way out

1. Restore a copy of the production DBs on a test server

2. Run a significative workload

3. Look at the Query Store for performance regressions

 Plan forced works across

 Recompilation

(18)

#SQLSAT454

Live Query Statistics

 Allows you to see the live execution plan of an

active query

 It provides a way to better understand the

query execution process and the control flow  It is extremely useful (and cool ) for

debugging query performance

 It is based on sys.dm_exec_query_profiles

(19)

#SQLSAT454

DEMO

(20)

#SQLSAT454

Live Query Statistics on SQL 2014 (SP1)

 At the server side

 Download and install the Service Pack 1 for SQL 2014 (if you have not already done)

 At the client side

 Download and install the latest version of SSMS (September 2015 preview)

 Enable the Live Query Statistics

 Play with it  on a test machine.. SQL Server will make some effort to produce the data for this tool!

(21)

#SQLSAT454

Summary: With Query Store you can..

Easily fix plan regressions Analyze your workload Find the most expensive queries De-risk SQL Server upgrades

(22)

#SQLSAT454

Resources

 [docs.com]

 SQL Server Query Store

 SQL Server 2016 Video Pills

(23)

#SQLSAT454

Q&A

(24)

#SQLSAT454

Evaluations

 Don’t forget to compile evaluations form here

 http://speakerscore.com/sqlsat454

(25)

#SQLSAT454

THANKS!

Thanks for attending this session. If you have additional questions, please post them on the MSDN SQL Server Forums (ITA | ENG)

#sqlsat454

References

Related documents

The problems identified by teachers are: Some of them include: Absenteeism, lateness and truancy of pupils from school; Lack of interest by pupils; Lack of materials

Previous studies, based on thin-layer electrochemistry (TLE), in situ scanning tunneling microscopy (EC-STM), high-resolution electron energy loss spectroscopy (HREELS) and

2 and Chinese markets, as represented by Hong Kong and the Hang Seng Index, not Shanghai and the Shanghai Composite Index, because the Spillover Index analysis, conducted in a VAR

For example, set one group to route SIP calls within your enterprise to an Avaya Converged Communications Server on your LAN, and set another group to route calls through your

Factors that contributed to false-negative results in PET/CT were determined in detecting clinically relevant lesions including malignant lesions, high-grade or villous adenomas,

The Dallas Opera Florida Grand Opera Houston Grand Opera Los Angeles Opera Lyric Opera of Chicago Minnesota Opera San Diego Opera San Francisco Opera The Santa Fe Opera Seattle

There is a clear case of market failure, both in the provision of suitable annuity products to meet the longevity risk, and in the provision of private insurance

•  Involve your student’s School Counselor •  Converse with the Instructional Team Leader.. •  Contact your