Query Profiling Options in SQL Server

Slides:



Advertisements
Similar presentations
Sponsored by: Professional Association for SQL Server Bad plan! Sit! Gail Shaw.
Advertisements

SQL Server Query Optimizer Cost Formulas Joe Chang
Troubleshooting SQL Server Enterprise Geodatabase Performance Issues
Denny Cherry Manager of Information Systems MVP, MCSA, MCDBA, MCTS, MCITP.
Cracking Execution Plans By Sarabpreet Singh Anand.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Learningcomputer.com SQL Server 2008 – Profiling and Monitoring Tools.
Query Optimizer Execution Plan Cost Model Joe Chang
Matt Lavery & Joanna Podgoetsky Being a DBA is cool again with SQL 2016 DAT335 A.
Dave LinkedIn
How to kill SQL Server Performance Håkan Winther.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP,MCP. SQL SERVER Database Administration.
SQL Server Deep Dive Denis Reznik Data Architect at Intapp.
Scott Fallen Sales Engineer, SQL Sentry Blog: scottfallen.blogspot.com.
Execution Plans Detail From Zero to Hero İsmail Adar.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP SQL SERVER Database Administration.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
Improve query performance with the new SQL Server 2016 query store!! Michelle Gutzait Principal Consultant at
A deep dive into SQL Server Plan Cache Management.
C:\Users\> whoami Known on Twitter t An affair with SQL Server for nearly a decade Was part of SQL Escalation Services and Premier Field.
Session Name Pelin ATICI SQL Premier Field Engineer.
SQL Server Magic Buttons! What are Trace Flags and why should I care? Steinar Andersen, SQL Service Nordic AB Thanks to Thomas Kejser for peer-reviewing.
Basic Outputs to Troubleshooting Queries.
Enhancements that will make your SQL database engine roar! SP1 Edition
SQL Server Statistics and its relationship with Query Optimizer
What Is The SSIS Catalog and Why Do I Care?
Troubleshooting SQL Server high CPU usage
Execution Planning for Success
Are You There, DBA? It’s Me, The App Developer.
SQL Server Data Collector From Every Angle
What's new with SQL Server 2016 and SQL Server vNext?
Reading execution plans successfully
Reading Execution Plans Successfully
Simplifying XEvents Management with dbatools
Parallel Database Maintenance with 24/7 Systems and Huge DBs
Performance Monitoring Using Extended Events, DMVs & Query Store
Statistics And New Cardinality Estimator (CE)
The Key to the Database Engine
Now where does THAT estimate come from?
Cardinality Estimator 2014/2016
Statistics What are the chances
Execution Plans Demystified
Statistics: What are they and How do I use them
In the name of the resources
SQL Server AG Monitoring and Troubleshooting
Reading Execution Plans Successfully
Hugo Kornelis Now where does THAT estimate come from? The nuts and bolts of cardinality estimation.
SQL Server Query Plans Journeyman and Beyond
Hidden Gems of SQL Server 2016
Introduction to reading execution plans
SQL Server Query Optimizer Cost Formulas
Parameter Sniffing: the Good, the Bad, and the Ugly
Dave Bland LinkedIn SQL Server Execution Plans: How to use them to find performance bottlenecks Dave Bland LinkedIn
Parameter Sniffing: the Good,the Bad, and the Ugly
Parameter Sniffing: the Good, the Bad, and the Ugly
Diving into Query Execution Plans
Analyzing Performance Problems Using XEvents, DMVs & Query Store
Introduction to Execution Plans
Denis Reznik SQL Server 2017 Hidden Gems.
Reading execution plans successfully
Introduction to Execution Plans
Extended Events: Successful troubleshooting recipes
Performance Tuning for SQL Developers through Execution Plans
Performance Tuning for SQL Developers through Execution Plans
Analyzing Performance Problems Using XEvents, DMVs & Query Store
Performance Tuning for SQL Developers through Execution Plans
Performance Tuning for SQL Developers through Execution Plans
Performance Tuning for SQL Developers through Execution Plans
Performance Tuning for SQL Developers through Execution Plans
Denis Reznik SQL Server 2017 Hidden Gems.
Presentation transcript:

Query Profiling Options in SQL Server Karol Papaj Query Profiling Options in SQL Server

Karol Papaj SolidQ SQL Server BI SQL Server High Availability SQL Server Relational Engine kpapaj@solidq.com @KarolPapaj http://kapa-consulting.sk/kapa-consulting/blog-en/

Execution plan with estimates What’s Execution Plan Instructions how to perform a given query Execution plan with estimates how many rows each node will have to process Execution plan with runtime statistics

Why we need Estimated Plan? Performance troubleshooting (why is your query slow?) Estimated Serial? Parallel? Seek? Scan? Loop?Merge?Hash? Serial? Parallel? Seek? Scan? Loop?Merge?Hash?

How Developer Can Get Estimated Plan SET SHOWPLAN_TEXT SET SHOWPLAN_XML SET SHOWPLAN_ALL Ctrl+L or “Display Estimated Execution Plan” in SSMS

How Developer Can Get Estimated Plan Demo How Developer Can Get Estimated Plan

Why we need Actual Plan? Performance troubleshooting (why is your query slow?) Actual Duration? SQL Server 2014 SP2 and higher Number of rows Cardinality estimation error? Missing filter condition Outdated statistics Memory used Threads used Degree of parallelism

How Developer Can Get Actual Plan SET STATISTICS PROFILE SET STATISTICS XML Ctrl+K or “Include Actual Execution Plan” in SSMS

How Developer Can Get Actual Plan Demo How Developer Can Get Actual Plan

How DBA Can Get Estimated Plan? Showplan XML event in Profiler query_pre_execution_showplan in Extended Events sys.dm_exec_cached_plans

How DBA Can Get Estimated Plan Demo How DBA Can Get Estimated Plan

How DBA Can Get Actual Plan? Showplan XML Statistics Profile in Profiler query_post_execution_showplan in Extended Events

How DBA Can Get Actual Plan Demo How DBA Can Get Actual Plan

2 Problems

1

Legacy profiling infrastructure CPU Overhead https://blogs.msdn.microsoft.com/sql_server_team/query-progress-anytime-anywhere/

Lightweight infrastructure SQL Server 2016 SP1 query_thread_profile extended event DBCC TRACEON(7412,-1) GO Enabled by TF 7412

Lightweight infrastructure Demo Lightweight infrastructure

Profiling Infrastructure CPU Overhead Source: https://blogs.msdn.microsoft.com/sql_server_team/query-progress-anytime-anywhere/

2

query_thread_profile QUERY_PLAN_PROFILE SQL 2016 SP2 CU3 SQL 2017 CU11 SQL 2019 query_thread_profile extended event SELECT COUNT (*) FROM Sales.SalesOrderHeaderEnlarged; OPTION (USE HINT('QUERY_PLAN_PROFILE')); QUERY_PLAN_PROFILE hint

Demo QUERY_PLAN_PROFILE

How to use QUERY_PLAN_PROFILE without touching a code Query_ID Profiling 1 2 Configuration table Plan Guide

QUERY_PLAN_PROFILE Practical Usage Demo QUERY_PLAN_PROFILE Practical Usage

Be careful on getting Actual Execution Plan from production on SQL Server before 2014 SP2/2016 SQL 2014 SP2/2016 better SQL 2016 SP1 much better (enable lightweight infrastructure if CPU usage is < 95% on your server) SQL Server 2019 has lightweight infrastructure enabled by default SQL 2016 SP2 CU3/2017 CU11/2019 even better! (query_plan_profile_hint)

QUESTIONS ? #SQLCLINIC

Resources MS SQL Tiger Team blog: https://blogs.msdn.microsoft.com/sql_server_team/query-progress-anytime-anywhere/ Execution Plan Reference by Hugo Kornelis: https://sqlserverfast.com/epr/

THANK YOU !