Query Tuning Fundamentals

Slides:



Advertisements
Similar presentations
SQL Server performance tuning basics
Advertisements

SQL Performance 2011/12 Joe Chang, SolidQ
Virtual techdays INDIA │ 9-11 February 2011 SQL 2008 Query Tuning Praveen Srivatsa │ Principal SME – StudyDesk91 │ Director, AsthraSoft Consulting │ Microsoft.
Tempdb Parasites Jason Hall-Dir. of Client SQL Sentry Blog-jasonhall.blogs.sqlsentry.net.
Denny Cherry Manager of Information Systems MVP, MCSA, MCDBA, MCTS, MCITP.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Meta Data Cardinality Explored CSSQLUG User Group - June 2009.
Dave LinkedIn
How to kill SQL Server Performance Håkan Winther.
Execution Plans Detail From Zero to Hero İsmail Adar.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
High Performance Functions SQLBits VI. Going backwards is faster than going forwards.
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.
SQL Server Statistics and its relationship with Query Optimizer
Parameter Sniffing in SQL Server Stored Procedures
Query Optimization Techniques
Stored Procedures – Facts and Myths
CS422 Principles of Database Systems Course Overview
Query Tuning without Production Data
T-SQL Coding Techniques Are you playing with fire?
Parameter Sniffing in SQL Server Stored Procedures
Query Tuning without Production Data
Query Tuning without Production Data
Reading execution plans successfully
Ouch! Our Data Type Choices Did THAT?
Reading Execution Plans Successfully
Introduction to Query Optimization
Introduction to Execution Plans
Query Execution Expectation-Reality Denis Reznik
Chapter 15 QUERY EXECUTION.
It’s About Time : Temporal Table Support in SQL Server 2016/2017
Marcos Freccia Stop everything! Top T-SQL tricks to a developer
Proper DataType Usage = Guaranteed Better Performance and Accuracy
The Key to the Database Engine
Performance Tuning for Mere Mortals Part II
Now where does THAT estimate come from?
Query Optimization Statistics: The Driving Force Behind Good Performance G. Vern Rabe -
It’s About Time : Temporal Table Support in SQL Server 2016/2017
Query Optimization Techniques
Execution Plans Demystified
Transactions, Locking and Query Optimisation
Performance Tuning for Mere Mortals Part II
When query plans go wrong
SQL Server Query Plans Journeyman and Beyond
Transact SQL Performance Tips
Parameter Sniffing: the Good, the Bad, and the Ugly
Introduction to Execution Plans
Parameter Sniffing: the Good,the Bad, and the Ugly
Parameter Sniffing: the Good, the Bad, and the Ugly
“Magic numbers”, local variable and performance
Dynamic Sql Not so scary?
Diving into Query Execution Plans
Query Optimization.
Are you following SQL Server Development Best Practices?
SQL Server Query Design and Optimization Recommendations
Introduction to Execution Plans
Sourav Mukherjee Are you following SQL Server Development Best Practices? March 30, 2019 Cincinnati.
Query Optimization Techniques
Reading execution plans successfully
T-SQL Basics: Coding for performance
Introduction to 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
Performance Tuning for SQL Developers through Execution Plans
Performance Tuning for SQL Developers through Execution Plans
Navigating SSMS Primer for Beginners
Performance Tuning for SQL Developers through Execution Plans
Presentation transcript:

Query Tuning Fundamentals

Vern Rabe Portland, OR independent consultant, trainer MCTA, MCDBA, MCSE, MCITP VP Oregon PASS chapter Working with/focusing on SQL Server since 1993, starting with SQL Server 4.21a

What We’ll Cover The Optimizer Tools Query Writing Suggestions Stored Procedures Triggers Views Indexes

The Optimizer What is it? What does it do? Not all plans considered (Good enough) Timeout? Statistics> Auto update statistics Auto create statistics

Tools What Resource (usually) has Most Performance Impact? I/O SET STATISTICS> SET STATISTICS IO ON SET STATISTICS TIME ON Execution Plan Estimated vs. Actual> Join types: Merge/Nested Loop/Hash Match Each has its place Execution Logging> “home grown”

Query Writing Suggestions Think set (avoid RBAR) Sometimes “chunk” NOLOCK (READUNCOMMITTED)> Avoid SELECT * in production code Unnecessary bits across the wire Plans often not as efficient> UNION vs. UNION ALL> Always include schema name SET NOCOUNT ON

Query Writing Suggestions SARGable> Watch out for Implicit Conversion> Avoid leading wild card comparisons Avoid user defined scalar functions in predicates> Limit number of JOINs DISTINCT Only UPDATE if something changed>

Stored Procedures Why stored procedures? Parameter Sniffing> Code modularity Pre-compiled Parameter Sniffing> WITH RECOMPILE OPTION (RECOMPILE) Branch Do not name a stored procedure “sp_”…

Triggers Can cause performance issues Try to use CONSTRAINT first Performance issues obfuscated Triggers code is not in Estimated Execution Plan>

Views Views per se are not a performance problem Abuse of views ARE a performance concern Views of views – too many joins and obfuscated Indexed (materialized) views

Not sure what should go here Thanks. Questions? Not sure what should go here vern@rabedata.com @VernRabe Vern Rabe

Thanks Questions? Contact information vern@rabedata.com LinkedIn www.linkedin.com/pub/vern-rabe/a/ba3/980 Resources Join operators http://www.madeira.co.il/loop-hash-and-merge-join-types/