Dave LinkedIn
13 years DBA Experience Teaching SQL Server since 1999 SQL Server Instructor at Harper College, Palatine, IL Currently supervise a team of DBAs DBA consultant for Einstein Technology Solutions, Lombard, IL
Certifications
How does SQL Server execute a query Types of Execution Plans Common query bottlenecks Plan Cache First Look at an Execution Plan Execution Plan Icons and Identifying potential performance bottlenecks SQL Sentry Plan Explorer
“ An execution plan, simply put, is the result of the query optimizer's attempt to calculate the most efficient way to implement the request represented by the T-SQL” Grant Fritchey - SQL Server Execution Plans Second Edition
Minimum permissions needed: ShowPlan in the database Members of Sysadmin role Members of DB_Owner
Disk I\O CPU Memory Network Poor query design Missing indexes Indexes not optimized Statistics out of date
Types of Plans ◦ Actual ◦ Estimated Displaying Execution Plans ◦ Graphical plans ◦ Text plans (deprecated) ◦ XML plans Saving ◦.SQLPLAN
Algebrizer process creates a hash of incoming query(DML Only) What flushes a plan from Cache ◦ Not enough memory ◦ DBCC FREEPROCCACHE ◦ Schema Changes to referenced objects ◦ Statistics used by the plan are updated ◦ Changes made to the stored procedure
Used for comparative purposes Float cursor over icon
Index Scan vs Index Seek Scan searches data pages Seek is preferred for highly selective queries If scan, check for index or a useful index
Usually considered less than optimal If table is very small may not be an issue If expecting an Index Scan or Seek: Update statistics Rebuild indexes Review query
Can be difficult to test on a development machine Some statements can force a serial plan
Use of cursor with sys.sp_Msforeachdb Data type conversions Foreign Key full table scan due to lack of index
Happens when joining on different data types Can lead to excessive CPU utilization Can occur in the FROM or the WHERE clause
In this case, this is the Estimated Execution plan, actual was more accurate
Only retrieve what you need Minimize use of temporary tables Avoid cursors Work with your DBA to arrange good indexes to support filters, joins and ordering Learn how to address tasks with different query approaches to compare performance
Must have a baseline for normal performance Establish at different times of day Document the baseline
Table redesign Redesign query More memory Add Indexes Optimize indexes Update statistics Reboot
Microsoft SQL Server 2014 Query Tuning and Optimization – Benjamin Nevarez Paul White Blog Paul White Blog
Understanding Parallelism Understanding Parallelism BrentOzar.com BrentOzar.com SQL Server Execution Plans – Grant Fritchey
DBA Blog