Kevin Kline Director of Engineering Services, SQL Sentry SQL Server MVP since 2003 Twitter, FB, LI: KEKline Blog:

Slides:



Advertisements
Similar presentations
Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
Advertisements

SQL Server performance tuning basics
Top Tuning Tools for SQL Server Kevin Kline & Aaron Bertrand SQL Sentry.
Aaron Bertrand SQL Sentry, Senior Kevin Kline SQL Sentry, Dir of Engineering
Aaron Bertrand SQL Sentry, Senior Kevin Kline SQL Sentry, Dir of Engineering
SQL Performance 2011/12 Joe Chang, SolidQ
5 Common SQL Server Performance Issues Jason Hall-SQL Sentry, Dir of Client Services Blog-jasonhall.blogs.sqlsentry.net.
Every SQL Programmer Should Know Kevin Kline Director of Engineering Services at SQL Sentry Microsoft MVP since 2003 Facebook, LinkedIn, Twitter at KEKLINE.
10 Things Not To Do With SQL SQLBits 7. Some things you shouldn’t do.
Comprehensive Performance with Automated Execution Plan Analysis (ExecStats) Joe Chang yahoo
Tempdb Parasites Jason Hall-Dir. of Client SQL Sentry Blog-jasonhall.blogs.sqlsentry.net.
Oracle 11g Real Application Testing: Avoiding Performance Regressions with SQL Performance Analyzer Khaled Yagoub, Pete Belknap, Benoit Dageville, Karl.
Kevin Kline, SQL Sentry Director of Engineering Services, Microsoft SQL Server MVP since 2003 Twitter, Facebook, KEKline.
Kevin Kline, SQL Sentry Director of Engineering Services, Microsoft SQL Server MVP since 2003 Twitter, Facebook, KEKline.
2 Avoiding Stored Procedure Recompiles Dr Greg Low Managing Director Solid Q Australia Session Code: DAT454.
Atlanta SQL Server Users Group April 10, 2006 Stored Procedure Best Practices Kevin Kline Director of Technology Quest Software.
1 Robert Wijnbelt Health Check your Database A Performance Tuning Methodology.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
TEMPDB Capacity Planning. Indexing Advantages – Increases performance – SQL server do not have to search all the rows. – Performance, Concurrency, Required.
Copyright © 2006 Quest Software Best Practices for Stored Procedures By Kevin Kline SQL Server MVP.
Top Free Tools for Tuning SQL Statements Kevin Kline & Aaron Bertrand SQL Sentry, Inc.
TOP10 DEV SKILLS TO MAKE YOUR DBA HAPPY Kevin Kline Director of Engineering Services, SQL Sentry SQL Server MVP since 2004 Twitter, FB, LI: KEKline Blog:
Effective Indexes For Beginners. Performance is slow Let’s add another index!
SQL Dev Tips for Small Workstations How to develop SQL on small dev workstations when prod is huge. Kevin Kline and Aaron Bertrand SQL Sentry.
SQL School is strongly committed to provide COMPLETE PRACTICAL REALTIME Trainings on SQL Server Technologies – Dev, SQL DBA, MSBI (SSIS, SSAS, SSRS) and.
Connect with life Nauzad Kapadia Quartz Systems
Query Optimization CMPE 226 Database Systems By, Arjun Gangisetty
SQL SERVER CONFIGURATION OPTIONS AND TRACE FLAG SECRETS Kevin Kline SQL Sentry, Director of Engineering on Twitter, FB, LI Blogs at
October 15-18, 2013 Charlotte, NC Accelerating Database Performance Using Compression Joseph D’Antoni, Solutions Architect Anexinet.
Dave LinkedIn
How to kill SQL Server Performance Håkan Winther.
Inside Query Processor Sort Dmitry Pilugin SQL Server Developer, MVP (RU) (EN)
Scott Fallen Sales Engineer, SQL Sentry Blog: scottfallen.blogspot.com.
Execution Plans Detail From Zero to Hero İsmail Adar.
Why Should I Care About … The Plan Cache? Tuning When Stakeholders Won’t Say Where It Hurts.
Diving into Query Execution Plans ED POLLACK AUTOTASK CORPORATION DATABASE OPTIMIZATION ENGINEER.
Session Name Pelin ATICI SQL Premier Field Engineer.
SQLSTARTER - INTRO TO DATABASE DEVELOPMENT Kevin Kline Technical Evangelist, SQL Sentry SQL Server MVP since 2003 Twitter, FB, LI, KEKline Blog:
Introducing Hekaton The next step in SQL Server OLTP performance Mladen Prajdić
SQL Server Statistics and its relationship with Query Optimizer
Chris Index Feng Shui Chris
Are You There, DBA? It’s Me, The App Developer.
Query Tuning without Production Data
Query Tuning without Production Data
Query Tuning without Production Data
Database Performance Tuning and Query Optimization
Reading Execution Plans Successfully
Introduction to Execution Plans
Statistics What are the chances
Top Tips for Better TSQL Stored Procedures
JULIE McLAIN-HARPER LINKEDIN: JM HARPER
Statistics: What are they and How do I use them
Steve Hood SimpleSQLServer.com
When query plans go wrong
Reading Execution Plans Successfully
Parameter Sniffing: the Good, the Bad, and the Ugly
SQL Server Performance Tuning
Dave Bland LinkedIn SQL Server Execution Plans: How to use them to find performance bottlenecks Dave Bland LinkedIn
Introduction to Execution Plans
Parameter Sniffing: the Good, the Bad, and the Ugly
Chapter 11 Database Performance Tuning and Query Optimization
Sioux Falls, SD | Hosted by (605) SQL
Diving into Query Execution Plans
SQL Server Query Design and Optimization Recommendations
Introduction to Execution Plans
Reading execution plans successfully
Introduction to Execution Plans
Using wait stats to determine why my server is slow
Performance Tuning for SQL Developers through Execution Plans
Performance Tuning for SQL Developers through Execution Plans
Presentation transcript:

Kevin Kline Director of Engineering Services, SQL Sentry SQL Server MVP since 2003 Twitter, FB, LI: KEKline Blog:

Tuning blog: for free copies of our

ToolsTechniques Process, Patterns & Practices Happy & Helpful DBA!

 DBAs:  Stodgy  Conservative  Slow  Control Freak  Dev’s say “Drats, thwarted again!”  The truth?  Our job is to act as the guardian of the true corporate IT assets.  Developers:  Cowboys  Reckless  Hasty  Chaotic  DBAs say “Blimey, my database is besmirched!”  The truth?  Our job is build products that are high quality, fast, and cheap (pick two).

Dev workstations are usually nothing like production: o Build representative data when you can. (Remember auto-update stats). o Build a stats-only database (a.k.a. db clone) for smaller dev environments o Ensure important settings are the same. o Simulate equivalent hardware: DBCC OPTIMIZER_WHATIF.

Warm caching or Cold caching? Measure: o Total elapsed time o Individual statement time o IO load Facilitates automation of execution plans Get to know the DMV sys.dm_exec_query_stats

The steps used by SQL Server to process a query are displayed in an execution plan. o Learn how to compare in SSMS. Better yet, use the free Plan Explorer product. o Learn how to watch in real-time with SQL Profiler or Extended Events. Comparative query performance might mislead: o Should evaluate on comparable data sizes. o Different CPU, disk, caching, etc. o Evaluate the query cost.

Red Flags Query Operators: Lookups, Scans, Spools, Parallelism Operations Other Red Flags: Dissimilar estimated versus actual row counts High physical reads Missing statistics alarms Large sort operations Implicit data type conversions

getord Plan Cache Memory finduser sp_1sp_ What about buffer cache?

Expected: Because we request it: CREATE PROC … WITH RECOMPILE or EXEC myproc … WITH RECOMPILE SP_RECOMPILE foo Expected: Plan was aged out of memory Unexpected: Interleaved DDL and DML Unexpected: Big changes since last execution: Schema changes to objects in underlying code New/updated index statistics Sp_configure Execution Load metadata NO In Memory? compile optimize Execute YES ReComp Execute

CREATE PROC testddldml AS … ; CREATE TABLE #testdml;-- (DDL) INSERT INTO #testdml;-- (DML + RECOMPILE) ALTER TABLE #testdml;-- (DDL) INSERT INTO #testdml;-- (DML + RECOMPILE) DROP TABLE #testdml;-- (DDL)

Cursors are usually unnecessary, but when they are, use the right options. The defaults are heavy-handed and guaranteed to be slow. Blog post:

Leaf pages are the DATA. Non-leaf pages are POINTERS, but are also data. 8K pages. Not always self-healing. Make sure they’re on your important search arguments, a.k.a. “sargs”. Leaf Pages Root Page Level 0 Intermediate Pages Level 1 Level 2

Big differences between a SELECT and a DML statement that effects the same rows. Shouldn’t blindly create every index the Tuning Advisor or execution plan tells you to! Blog post -

SQL Server has to do a lot of extra work / scans when conversion operations are assumed by the SQL programmer. Happens all the time with data types you’d think wouldn’t need it, e.g. between date types and character types. Very useful data type conversion chart at Data type precedence call also have an impact:

Which are better, temp tables or temp variables? Temp TableTemp Variable Stored in?Tempdb Statistics?YesNo (1 row) Indexs/Keys?Yes1 UK / PK only Truncate?YesNo Recompiles?YesNo Parallelism?YesNo Metadata Overhead? LowLowest Lock Overhead?NormalLowest

Coding standards. Parameterization. Remember the power of specialized code. More details:

Mimic production as best you can Test harness & testing Read execution plans Get to know the plan cache Avoid unwanted recompiles Use cursors appropriately Create useful and balanced indexes Write code that doesn’t break indexes Temp variables <> pure goodness Prevent cache bloat

PLEASE FILL OUT THE SESSION EVAL! Send questions to me at: Twitter, Facebook, LinkedIn at KEKline Slides at and now at Slideshare.Nethttp://KevinEKline.com/Slides/ IT leadership and soft skills content at THANK YOU!