SQL Server Query and Index Tuning

Slides:



Advertisements
Similar presentations
Understanding SQL Server Query Execution Plans
Advertisements

SQL Server performance tuning basics
10 Things Not To Do With SQL SQLBits 7. Some things you shouldn’t do.
Working with SQL Server Database Objects
SQL Server Storage and Index Structures Physical Data Organization Indexes B-Trees SQL Server Data Access Clustered and Non-Clustered Creating, Altering,
Architecting a Large-Scale Data Warehouse with SQL Server 2005 Mark Morton Senior Technical Consultant IT Training Solutions DAT313.
Module 8 Improving Performance through Nonclustered Indexes.
Insert, Update & Delete Performance Joe Chang
Module 5 Planning for SQL Server® 2008 R2 Indexing.
SQL Server Indexes Indexes. Overview Indexes are used to help speed search results in a database. A careful use of indexes can greatly improve search.
T-SQL: Simple Changes That Go a Long Way DAVE ingeniousSQL.com linkedin.com/in/ingenioussql.
Indexes / Session 2/ 1 of 36 Session 2 Module 3: Types of Indexes Module 4: Maintaining Indexes.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
SQLintersection Putting the "Squeeze" on Large Tables Improve Performance and Save Space with Data Compression Justin Randall Tuesday,
Chapter 4 Indexes. Index Architecture  By default data is inserted on a first-come, first-serve basis  Indexes bring order to this chaos  Once you.
Session 1 Module 1: Introduction to Data Integrity
Creating Indexes on Tables An index provides quick access to data in a table, based on the values in specified columns. A table can have more than one.
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
Indexing Fundamentals Steve Hood SimpleSQLServer.com.
Table Structures and Indexing. The concept of indexing If you were asked to search for the name “Adam Wilbert” in a phonebook, you would go directly to.
SYSTEM CENTER VIRTUAL MACHINE MANAGER 2012 Gorazd Šemrov Microsoft Consulting Services
Copyright Sammamish Software Services All rights reserved. 1 Prog 140  SQL Server Performance Monitoring and Tuning.
HOL: 1: USING MICROSOFT EXCHANGE SERVER 2010 SP1 – MOBILITY FEATUERS 2: MICROSOFT EXCHANGE SERVER 2010 SP1 HIGH AVAILABILITY AND STORAGE SCENARIOS Gašper.
How to kill SQL Server Performance Håkan Winther.
APRIL 13 th Introduction About me Duško Mirković 7 years of experience.
Scott Fallen Sales Engineer, SQL Sentry Blog: scottfallen.blogspot.com.
Execution Plans Detail From Zero to Hero İsmail Adar.
SQL Server 2008 R2 Introduction Dejan Sarka Solid Quality Mentors
Module 6: Creating and Maintaining Indexes. Overview Creating Indexes Understanding Index Creation Options Maintaining Indexes Introducing Statistics.
KORAK PRED OSTALIMI VISUAL STUDIO LIGHTSWITCH Danijel Malik Artifis Danijel Malik s.p.
High Performance Functions SQLBits VI. Going backwards is faster than going forwards.
SHAREPOINT GRANULAR RECOVERY MODULE Igor Lautar, Mladen Brajković.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Miroslav Pavleski (SETCCE)
Chris Index Feng Shui Chris
Query Optimization Techniques
Troubleshooting SQL Server high CPU usage
VS 11 & TFS 11 Danijel Malik Artifis Danijel Malik s.p.
Indexes By Adrienne Watt.
CS 540 Database Management Systems
Surface 2.0 – what is new? Jernej Kavka, Semantika d.o.o.
Advanced SQL Programming for SQL Server 2008
T-SQL: Simple Changes That Go a Long Way
SQL Server Monitoring Overview
Module 4: Creating and Tuning Indexes
Designing Database Solutions for SQL Server
Hustle and Bustle of SQL Pages
The Ins and Outs of Indexes
Marcos Freccia Stop everything! Top T-SQL tricks to a developer
The Ins and Outs of Indexes
Getting To Know Your Indexes
Indexing Fundamentals
Indexes: The Basics Kathi Kellenberger.
Statistics: What are they and How do I use them
Steve Hood SimpleSQLServer.com
The Ins and Outs of Indexes
Indexing for Beginners
Database systems Lecture 6 – Indexes
මොඩියුල විශ්ලේෂණය SQL Server Waits. Tables රැසක් එකට එකතු කිරීම.
Targeting Wait Statistics with Extended Events
Indexing For Optimal Performance
Data Management Innovations 2017 High level overview of DB
Index Tuning Additional knowledge.
Execution plans Eugene
The Ins and Outs of Indexes
Query Optimization Techniques
Welcome!.
All about Indexes Gail Shaw.
Advanced Database Topics
The Ins and Outs of Indexes
Presentation transcript:

SQL Server Query and Index Tuning Mladen Prajdić dSolutions SI

About me 1999...

Server troubleshooting Data structures Agenda Server troubleshooting Data structures Indexing practices and troubleshooting Query tuning

Server troubleshootinG Perfmon SQL Profiler, SQL Trace Event Notifications Extended Events DMVs sys.dm_os_wait_stats sys.dm_exec_requests sys.dm_exec_sql_text sys.dm_exec_query_plan sys.dm_tran_locks

Server troubleshooting Data structures Agenda Server troubleshooting Data structures Indexing practices and troubleshooting Query tuning

Data Pages in no logical order No page deallocations with delete Data structures HEAP Bulk inserts Staging tables Data Pages in no logical order No page deallocations with delete

Data structures clustered index Data pages are logically ordered All data on the leaf node Fill factor Uniquifier

Data structures Nonclustered index Pointers to actual pages with data CI key or RID Uniquifier Included columns

Server troubleshooting Data structures Agenda Server troubleshooting Data structures Indexing practices and troubleshooting Query tuning

Indexing practices and troubleshooting THE ENDLESS CLUSTERED INDEX DEBATE Clustered index <> Primary Key Int, DateTime, Guid, Composite columns Page splits Fragmentation (CI and NCI)

Indexing practices and troubleshooting THE ENDLESS CLUSTERED INDEX DEBATE Type CI width (b) Rows NCI num Size(Mb) INT 4 1.500.000 10 57.2 DATETIME 8 114.5 GUID 16 228.9 OTHER 32 457.8 Know your data!

Indexing practices and troubleshooting Problem? Diagnose Tune Test INDEX ANALYSIS

Indexing practices and troubleshooting MISSING INDEXES 3 DMVs, Database Tuning Advisor, SSMS suggestions UNUSED INDEXES sys.dm_db_index_usage_stats FRAGMENTED INDEXES sys.dm_db_index_physical_stats

Indexing practices and troubleshooting INDEXING POINTERS Foreign keys One multicolumn or multiple single column indexes Beware of Bookmark Lookup Included columns

Indexing practices and troubleshooting TIPPING POINT Only valid for non-covering nonclustered indexes

Indexing practices and troubleshooting ENTERPRISE EDITION FEATURES Compresion sp_estimate_data_compression_savings Filtered indexes Somewhat limited functionality

Indexing practices and troubleshooting STATISTICS Value frequency histogram Async auto update stats Needed to build better execution plans Multicolumn, Custom and Filtered stats

Indexing practices and troubleshooting STATISTICS

Indexing practices and troubleshooting QUICK SUMMARY Narrow, increasing values for keys Try to eliminate bookmark lookup Included columns are your friend Statistics maintenance

Server troubleshooting Data structures Agenda Server troubleshooting Data structures Indexing practices and troubleshooting Query tuning

SQL Profiler, SQL Trace, Extended events SET STATISTICS IO Query tuning SQL Profiler, SQL Trace, Extended events SET STATISTICS IO SET STATISTICS TIME Execution Plans Minimize logical reads and CPU

Solution for every performance problem Query tuning Solution for every performance problem NOLOCK JUST KIDDING 

Report query with UDF and correlated subqueries in the select list Query TunNing Example: Report query with UDF and correlated subqueries in the select list We‘ll make it GO FASTER! 

Forced Parameterization „Magic“ bullets Forced Parameterization Optimize for ad hoc workloads

Don‘t just add or remove indexes blindly Think set based Summary Know your data Don‘t just add or remove indexes blindly Think set based Scalar UDFs bad, Table valued UDFs good Use CROSS APPLY

VPRAŠANJA? Po zaključku predavanja prosim izpolnite vprašalnik. Vprašalniki bodo poslani na vaš e-naslov, dostopni pa bodo tudi preko profila na spletnem portalu konference. www.ntk.si . Z izpolnjevanjem le tega pripomorete k izboljšanju konference. Hvala!