SQL Server Performance Tuning

Slides:



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

Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Intro to SQL Server Performance Tuning By Robert Biddle.
How to solve a SQL performance problem Paul Zgondea.
Informix IDS Administration with the New Server Studio 4.0 By Lester Knutsen My experience with the beta of Server Studio and the new Informix database.
Meta Data Cardinality Explored CSSQLUG User Group - June 2009.
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
What is Data Science and Who is Data Scientist
Deadlocks 3.0. Final Edition. Everything that developer needs to know Denis Reznik Microsoft SQL Server MVP Director of R&D at Intapp Kyiv.
SQL Server Deep Dive Denis Reznik Data Architect at Intapp.
Execution Plans Detail From Zero to Hero İsmail Adar.
MongoDB for SQL Developers Ben Galluzzo SQL Saturday #395 – Baltimore - BI Edition 2015.
Configuring SQL Server for a successful SharePoint Server Deployment Haaron Gonzalez Solution Architect & Consultant Microsoft MVP SharePoint Server
CSS Microsoft Korea. Data Collector Management Data Warehouse Performance and Configuration Reports Graphical Showplan Activity Monitor SQL Profiler Dynamic.
Eli Robillard Microsoft Office Server & Services
Planning a Migration.
Denis Reznik Data Architect, Intapp, Inc. Microsoft Data Platform MVP
An introduction to Wait Statistics
Parameter Sniffing in SQL Server Stored Procedures
Thank You! #sqlsatdnipro Denis
Stored Procedures – Facts and Myths
Parameter Sniffing in SQL Server Stored Procedures
Reading execution plans successfully
Did your feature got in, out or planned?
Chapter Overview Understanding the Database Architecture
Hustle and Bustle of SQL Pages
Reading Execution Plans Successfully
Introduction to Execution Plans
Query Execution Expectation-Reality Denis Reznik
The Ins and Outs of Indexes
Marcos Freccia Stop everything! Top T-SQL tricks to a developer
What is the Azure SQL Datawarehouse?
The Vocabulary of Performance Tuning
The Ins and Outs of Indexes
The Vocabulary of Performance Tuning
Implementing AI solutions using the cognitive services in Azure
Query Optimization Techniques
The Vocabulary of Performance Tuning
It’s Always a Hard Choice
Everything you ever wanted to ask but were too shy
SQL Server 2014 Hidden Treasures Denis Reznik Microsoft SQL Server MVP
Hidden Gems of SQL Server 2014
Hidden gems of SQL Server 2016
When query plans go wrong
SQL Server Performance Tuning Nowadays
Hidden Gems of SQL Server 2016
The PROCESS of Queries John Deardurff Website: ThatAwesomeTrainer.com
Query Processing CSD305 Advanced Databases.
The Vocabulary of Performance Tuning
Hidden Gems of SQL Server 2014
SQL Server Management Studio Tips and Tricks
Introduction to Execution Plans
Parameter Sniffing on SQL Server
Deadlocks Everything you ever wanted to ask but were too shy
Hidden Gems of SQL Server 2014
EXECUTION PLANS Quick Dive.
Hidden Gems of SQL Server 2014
SQL Server Query Design and Optimization Recommendations
Introduction to Execution Plans
The Five Mistakes You are Probably Making with SQL Server
Denis Reznik SQL Server 2017 Hidden Gems.
The Vocabulary of Performance Tuning
Introduction to Execution Plans
Why should I care about SQL, if I have ORM?
Power BI Infographic related on the Power BI Eco System
DEV2DEV Performance tips for faster SQL queries
All about Indexes Gail Shaw.
The Ins and Outs of Indexes
Denis Reznik SQL Server 2017 Hidden Gems.
Presentation transcript:

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

Sponsors Gold sponsors: Silver sponsors: Bronze sponsors:

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”

Agenda Data Collection Data Analysis Query Optimization 4 |

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

Indexes and Statistics Quick Overview

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

… … Clustered Index 1 .. 1M 1 .. 2K 2K+1 .. 4K 1M-2K .. 1M 1 .. 300 301 .. 800 801 .. 1,5K 1,5K+1 .. 2K …

… … Index Seek SELECT * FROM Users WHERE Id = 523 1 .. 1M 1 .. 2K 2K+1 .. 4K 1M-2K .. 1M … 1 .. 300 301 .. 800 801 .. 1,5K 1,5K+1 .. 2K …

… … Index Scan SELECT * FROM Users 1 .. 1M 1 .. 2K 2K+1 .. 4K 1M-2K .. 1M … 1 .. 300 301 .. 800 801 .. 1,5K 1,5K+1 .. 2K …

… … Index Range Scan SELECT * FROM Users WHERE Id BETWEEN 700 AND 1700 1 .. 2K 2K+1 .. 4K 1M-2K .. 1M … 1 .. 300 301 .. 800 801 .. 1,5K 1,5K+1 .. 2K …

… … 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+1 .. 4K 1M-2K .. 1M …

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+1 .. 4K 1M-2K .. 1M …

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

Parameter Sniffing and Dynamic SQL Quick Overview

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

Parameter Sniffing - Parametrized Query Query Processor sp_executesql N'SELECT * FROM Users WHERE Id = @Id', N'@Id int', 1 SELECT * FROM Users WHERE Id = @Id SELECT * FROM Users WHERE Id = @Id sp_executesql N'SELECT * FROM Users WHERE Id = @Id', N'@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

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.

Summary Data Collection Data Analysis Query Optimization 19 |

Sponsors Gold sponsors: Silver sponsors: Bronze sponsors:

Thank You! Denis Reznik @denisreznik denisreznik@live.ru