Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL Server Performance Tuning

Similar presentations


Presentation on theme: "SQL Server Performance Tuning"— Presentation transcript:

1 SQL Server Performance Tuning
Old-School Practical Guide Denis Reznik Data Architect at Intapp Microsoft Data Platform MVP

2 Sponsors Gold sponsors: Silver sponsors: Bronze sponsors:

3 About me Denis Reznik Kyiv, Ukraine Data Architect at Intapp
Microsoft Data Platform MVP Co-Founder of Ukrainian Data Community Kyiv Co-author of “SQL Server MVP Deep Dives 2”

4 Agenda Data Collection Data Analysis Query Optimization 4 |

5 SQL Server Management Studio
Tools SQL Profiler Performance Monitor SQL Server Management Studio

6 Indexes and Statistics
Quick Overview

7 Heap 1K .. 5K 12K .. 15K 22K .. 41K 7K .. 8K 51K .. 71K k 6K .. 7K 10K .. 11K 9K .. 10K 8K .. 9K 1M .. 2M 5K .. 6K 15K .. 21K 21K .. 22K 41K .. 51K 71K .. 1M 2M .. 3M

8 … … Clustered Index 1 .. 1M 1 .. 2K 2K+1 .. 4K 1M-2K .. 1M 1 .. 300
,5K 1,5K K

9 … … Index Seek SELECT * FROM Users WHERE Id = 523 1 .. 1M 1 .. 2K
2K K 1M-2K .. 1M ,5K 1,5K K

10 … … Index Scan SELECT * FROM Users 1 .. 1M 1 .. 2K 2K+1 .. 4K
1M-2K .. 1M ,5K 1,5K K

11 … … Index Range Scan SELECT * FROM Users WHERE Id BETWEEN 700 AND 1700
1 .. 2K 2K K 1M-2K .. 1M ,5K 1,5K K

12 … … Non-Clustered Index Non-Clustered Index (Name) SELECT * FROM Users
A .. Z SELECT * FROM Users WHERE Name = 'John Dow' A .. C C .. K X .. Z Clustered Index (Id) 1 .. 1M Heap 1 .. 2K 2K .. 4K 1M-2K .. 1M 1 .. 2K 2K K 1M-2K .. 1M

13 Index Allocation Map (IAM)
Allocation Order Scan Index Allocation Map (IAM) Extent 1 Extent 2 Clustered Index (Id) Extent N 1 .. 1M Extent 1 Extent N 1 .. 2K 2K K 1M-2K .. 1M

14 Statistics SELECT * FROM Users WHERE Id BETWEEN 2100 AND 2500
800 2000 2800 4500 5400

15 Parameter Sniffing and Dynamic SQL
Quick Overview

16 Parameter Sniffing - Stored Procedure
Query Processor EXEC AnnualSalesReport @UserId = 1 EXEC AnnualSalesReport @UserId = 22 SQL Server Cache Procedure cache Procedure cache Query executes using the query plan created for @UserId = 1 Plan created and cached for the @UserId = 1

17 Parameter Sniffing - Parametrized Query
Query Processor sp_executesql N'SELECT * FROM Users WHERE Id int', 1 SELECT * FROM Users WHERE Id SELECT * FROM Users WHERE Id sp_executesql N'SELECT * FROM Users WHERE Id int', 22 SQL Server Cache Procedure cache Procedure cache Plan created and cached for the @Id = 1 Query executes using the query plan created for @Id = 1

18 Dynamic SQL – Multiple Plans
Query Processor SELECT * FROM Users WHERE Id = 1 SELECT * FROM Users WHERE Id = 22 SQL Server Cache SELECT * FROM Users WHERE Id = 1 Procedure cache Procedure cache Procedure cache Query executed using the query plan, created for the first query. New query plan created and cached. Query executed using newly created plan. New query plan again created and cached. Query executed using newly created plan.

19 Summary Data Collection Data Analysis Query Optimization 19 |

20 Sponsors Gold sponsors: Silver sponsors: Bronze sponsors:

21 Thank You! Denis Reznik @denisreznik


Download ppt "SQL Server Performance Tuning"

Similar presentations


Ads by Google