Presentation is loading. Please wait.

Presentation is loading. Please wait.

Performance Tuning for SQL Developers through Execution Plans

Similar presentations


Presentation on theme: "Performance Tuning for SQL Developers through Execution Plans"— Presentation transcript:

1 Performance Tuning for SQL Developers through Execution Plans
Vladimir Oselsky Performance Tuning for SQL Developers through Execution Plans

2 About the Speaker Vladimir Oselsky (Vlady)
@VladyOselsky (Twitter), voselsky (LinkedIn) Born and raised in Siberia (it does get cold, and sometimes hot) B.S. Software Engineering Technology (I know some .NET) Various IT Jobs since 1998. Starting in 2010 worked with SQL Server and Oracle.

3 Execution Plans Is an attempt of SQL Server optimizer to calculate the most optimal route to retrieve the data. Estimated Plan: Possible plan SQL Server will use when executing a query. Actual Plan: Actual plan SQL Server used when executing a query.

4 Execution Plan Graphical Text XML
Graphical representation of steps SQL Server took to execute the query. (Easy to Read) Text Textual representation of steps, containing details about every operation. (Hard to Read) SHOWPLAN_ALL, SHOWPLAN_TEXT, STATISTICS PROFILE XML XML representation of steps outlined in structured way. (Maybe easy for some)

5 Plan Cache Plan Cache – The place SQL Server stores actual and estimated plans. Lazywriter – process that cleans up plans from Plan Cache based on age and complexity. DBCC FREEPROCCACHE – command to clear plan cache (DO NOT RUN IN PROD)

6 Plan Basics Button for displaying Estimated Execution Plan

7 Plan Basics Plans are read from RIGHT to LEFT.
Note: Mention extra time to run Query.

8 Plan Basics To get more details need to hover over specific icons or view properties screen Note: Mention extra time to run Query.

9 Plan Basics To get more details need to hover over specific icons or view properties screen Note: Mention extra time to run Query.

10 Plan Basics Text plan. Note: Mention extra time to run Query.

11 Plan Basics STATISTICS IO – Outputs information related to execution to messages tab Note: Mention extra time to run Query.

12 Plan Basics STATISTICS TIME – Outputs information related to execution to messages tab Note: Mention extra time to run Query.

13 Plan Basics XML Plan – One options is to run SHOWPLAN_XML command or right click on Actual Plan and select Show PLAN XML Option Note: Mention extra time to run Query.

14 XML Plan Note: Mention extra time to run Query.

15 Stored Plans System views can used to retrieve stored plans – DEMO 01
SELECT [cp].[refcounts] , [cp].[usecounts] , [cp].[objtype] , [st].[dbid] , [st].[objectid] , [st].[text] , [qp].[query_plan] FROM sys.dm_exec_cached_plans cp CROSS APPLY sys.dm_exec_sql_text( cp.plan_handle ) st CROSS APPLY sys.dm_exec_query_plan( cp.plan_handle ) qp; Note: Mention extra time to run Query.

16 Plan vs Plan Estimated vs Actual may be different Stale Statistics
Estimated Plans are invalid - DEMO 02 Cost for Parallelism is reached Note: Mention extra time to run Query.

17 Graphical Plan Explained
Reference Material for further reading List of all operators for SQL Server 2008R2 List of all operators for SQL Server 2017 Note: Mention extra time to run Query.

18 Possible Problems Scan Operations
Note: Mention extra time to run Query.

19 Possible Problems Other performance hindering candidates
Note: Mention extra time to run Query.

20 Possible Problems Other performance hindering candidates
Note: Mention extra time to run Query.

21 Possible Problems Physical JOIN Operations – DEMO 03 HASH MERGE LOOP
Note: Mention extra time to run Query.

22 Possible Problems IMPLICIT CONVERSION – DEMO 04
Note: Mention extra time to run Query.

23 SentryOne Demo Download:

24 Q&A Send questions to: vlady.oselsky@gmail.com
Blog: Thank you

25 Presentation has ended. Error code #20181120
If you like to know more, feel free to questions to: NOTE: All communication sent to incorrect address will be ignored.


Download ppt "Performance Tuning for SQL Developers through Execution Plans"

Similar presentations


Ads by Google