How Good Is Your Indexing Strategy?

Slides:



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

© IBM Corporation Informix Chat with the Labs John F. Miller III Unlocking the Mysteries Behind Update Statistics STSM.
A HEAP OF CLUSTERS A look into heaps vs. clustered tables Ami Levin CTO, DBSophic X.
Denny Cherry twitter.com/mrdenny.
Partitioning Design For Performance and Maintainability Martin Cairns
Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
Effective Indexes For Beginners. Performance is slow Let’s add another index!
Denny Cherry twitter.com/mrdenny.
Interpreting DMV’s & practical uses Jannie Muller mullerjannie.wordpress.com.
SQLintersection Putting the "Squeeze" on Large Tables Improve Performance and Save Space with Data Compression Justin Randall Tuesday,
SQL SERVER DAYS 2011 Table Indexing for the.NET Developer Denny Cherry twitter.com/mrdenny.
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.
Analysing Indexes SQLBits 6 th October 2007 © Colin Leversuch-Roberts Kelem Consulting Limited September 2007.
Pinal Dave Mentor | Solid Quality India |
Copyright Sammamish Software Services All rights reserved. 1 Prog 140  SQL Server Performance Monitoring and Tuning.
October 15-18, 2013 Charlotte, NC SQL Server Index Internals Tim Chapman Premier Field Engineer.
Linkedin: dennisegraham Dennis E Graham Reporting For SQL Health.
SQL Server Performance Tuning
Chris Index Feng Shui Chris
An introduction to Wait Statistics
Jonathan Walpole Computer Science Portland State University
Module 11: File Structure
15.1 – Introduction to physical-Query-plan operators
Learning indexing concepts with an analog phone book
SQL Server Query and Index Tuning
Physical Changes That Don’t Change the Logical Design
Query Performance Tuning: Start to Finish
Four-digit Place Value, Partitioning, Ordering and Counting by 10s, 100s, 1000s Place Value 17.
Efficiently Searching Schema in SQL Server
Finding more space for your tight environment
CSE-291 (Cloud Computing) Fall 2016
Inside of SQL Server Indexes
Parameter Sniffing in SQL Server Stored Procedures
SQL Server Monitoring Overview
Module 4: Creating and Tuning Indexes
Chapter 12: Query Processing
Please Support Our Sponsors
Reading Execution Plans Successfully
Chapter 15 QUERY EXECUTION.
The Ins and Outs of Indexes
Marcos Freccia Stop everything! Top T-SQL tricks to a developer
From 4 Minutes to 8 Seconds in an Hour (or a bit less)
Instant Add Columns in MySQL
The Ins and Outs of Indexes
Getting To Know Your Indexes
Table Indexing for the .NET Developer
Azure SQL Data Warehouse Performance Tuning
What Is a Latch? …and Why Do I Care? Eddie Wuerch, mcm
Query Optimization Techniques
B-Trees.
JULIE McLAIN-HARPER LINKEDIN: JM HARPER
Execution Plans Demystified
Indexes: The Basics Kathi Kellenberger.
The Ins and Outs of Indexes
Tracking Index Usage Like a Pro
SQL Server Query Plans Journeyman and Beyond
Indexing For Optimal Performance
Dynamic Management Views a practical overview!
Four Rules For Columnstore Query Performance
Please Support our Sponsors
Dynamic Management Views a practical overview!
The Ins and Outs of Indexes
Diving into Query Execution Plans
Tracking Index Usage Like a Pro
Analyzing Performance Problems Using XEvents, DMVs & Query Store
Query Optimization Techniques
The Five Mistakes You are Probably Making with SQL Server
All about Indexes Gail Shaw.
Advanced Database Topics
The Ins and Outs of Indexes
Presentation transcript:

How Good Is Your Indexing Strategy? MICROSOFT DATA PLATFORM MVP FOUNDER: SQL CRUISE & B-SIDE CONSULTING SENIOR DBA: SURVEYMONKEY TIM FORD

PASS Board of Directors WHO IS TIM? MVP Since 2009 SQL Cruise Since 2010 Author PASS Board of Directors Senior DBA

CONTACT POINTS thesqlagentman.com SQLCruise.com tim@sqlcruise.com @sqlagentman @sqlcruise

GOALS AGENDA FAMILIARITY WITH INDEX-RELATED SYSTEM OBJECTS UNDERSTAND HOW THE PIECES FIT TOGETHER UNDERSTAND WHAT QUESTIONS CAN BE ANSWERED AGENDA INTRODUCTION: WHY ARE INDEXES IMPORTANT HOW DOES INDEXING GET IN THE WAY? WHAT MAKES FOR A GOOD INDEX? TOUR THE INDEXING DYNAMIC MANAGEMENT OBJECTS MY GIFT TO YOU: THE SCRIPTS AND WHAT THEY ANSWER

WHY INDEX? PERFORMANCE BOOST ON READ OPERATIONS LESS IO MORE EFFICIENT QUERY PLANS

HOW DOES INDEXING GET IN THE WAY? Appropriate: we don’t want to index columns that are not used for reads Fill factor too high and you get page splits; too low and you are not making efficient use of your index space allocated Fragmentation leads to inefficient index read and write operations – adding time and IO Locks & Blocks

WHAT MAKES FOR A “GOOD” INDEX? INDEXING STRATEGY KEY ANALYSIS POINTS HIGH READ:WRITE RATIO APPROPRIATENESS REASONABLE FILL FACTOR HEALTHY FRAGMENTATION Appropriate: we don’t want to index columns that are not used for reads Fill factor too high and you get page splits; too low and you are not making efficient use of your index space allocated Fragmentation leads to inefficient index read and write operations – adding time and IO

INDEXING DMOs TOOLS AND ANALYSIS INDEXING DMOs USAGE COUNTERS DM_DB_INDEX_USAGE_STATS PHYSICAL METRICS DM_DB_INDEX_PHYSICAL_STATS LOCK/LATCH/SPLIT STATISTICS DM_DB_INDEX_OPERATIONAL_STATS MISSING INDEX DMOs DM_DB_MISSING_INDEX_COLUMNS DM_DB_MISSING_INDEX_DETAILS DM_DB_MISSING_INDEX_GROUP_STATS DM_DB_MISSING_INDEX_GROUPS

USAGE STATISTICS SELECT * FROM sys.dm_db_index_usage_stats Returns cumulative scan, seek, lookup, update counts and last action times for these operations for each heap or index in the database for both user actions as well as system operations against these objects

CRITICAL COLUMNS COLUMN NAME WHY IT MATTERS DATABASE_ID IDENTIFICATION OBJECT_ID IDENTIFICATION INDEX_ID IDENTIFICATION USER_SEEKS COUNT OF USER-INITIATED SEEKS USER_SCANS COUNT OF USER-INITIATED SCANS USER_LOOKUPS COUNT OF USER-INITIATED LOOKUPS USER_UPDATES COUNT OF USER-INITIATED WRITES LAST_USER_SEEK … UPDATE LAST TIME THIS OPERATION HAPPENED

PHYSICAL METRICS SELECT * FROM sys.dm_db_index_physical_stats (database_id , object_id , index_id , partition_id , ‘limited’ | ‘detailed’ | ‘sampled’) Returns fragmentation, structural definitions, space usage, and compression metrics for each partition of a table or index in the database

CRITICAL COLUMNS COLUMN NAME WHY IT MATTERS DATABASE_ID IDENTIFICATION OBJECT_ID IDENTIFICATION INDEX_ID IDENTIFICATION PARTITION_ID IDENTIFICATION INDEX_TYPE_DESC HEAP | CLUSTERED | NON-CLUSTERED ALLOC_UNIT_TYPE_DESC LOB OR NON-LOB DATA AVG_FRAGMENTATION_IN_PCT FRAGMENTATION METRIC PAGE_COUNT SIZE RECORD_COUNT HOW MANY RECORDS AVG_RECORD_SIZE_IN_BYTES AVERGAGE SIZE OF EACH RECORD

OPERATIONAL STATISTICS SELECT * FROM sys.dm_db_index_operational_stats (database_id , object_id , index_id , partition_id) Returns cumulative I/O, locking, latching, and access method activity as well as page split metrics for each partition of a table or index in the database

CRITICAL COLUMNS COLUMN NAME WHY IT MATTERS DATABASE_ID IDENTIFICATION OBJECT_ID IDENTIFICATION INDEX_ID IDENTIFICATION PARTITION_ID IDENTIFICATION LEAF_ALLOCATION_COUNT LEAF-LEVEL PAGE SPLITS NONLEAF_ALLOCATION_COUNT NON-LEAF-LEVEL PAGE SPLITS

CRITICAL COLUMNS - continued COLUMN NAME WHY IT MATTERS PAGE_LOCK_WAIT_COUNT NUMBER OF PAGE LOCK WAITS PAGE_LOCK_WAIT_IN_MS PAGE LOCK WAITS IN MILLISECONDS PAGE_LATCH_WAIT_COUNT NUMBER OF PAGE LATCH WAITS PAGE_LATCH_WAIT_IN_MS PAGE LATCH WAITS IN MILLISECONDS PAGE_IO_LATCH_WAIT_COUNT NUMBER OF PAGE IO LATCH WAITS PAGE_IO_LATCH_WAIT_IN_MS PAGE IO LATCH WAITS IN MILLISECONDS

SYSTEM VIEWS TOOLS AND ANALYSIS OBJECT NAME INDEX METADATA SYS.INDEXES INDEX COLUMN METADATA SYS.INDEX_COLUMNS TABLE OBJECT METADATA SYS.TABLES COLUMN METADATA SYS.COLUMNS DATA TYPE METADATA SYS.TYPES

INDEX METADATA ECOSYSTEM database_id IXPS IXUS IXOS INDEX METADATA ECOSYSTEM object_id index_id DMOs System Views sys.tables sys.indexes column_id sys.columns sys.index_columns system_type_id & user_type_id KEY DMV column DMF sys.types SYSTEM VIEW

QUESTIONS… ANSWERED USAGE Which tables are read from | written to most | least? Which tables have no activity since last restart | rebuild? What are the use patterns for all indexes? PHYSICAL What are my largest indexes? Which indexes are fragmented? Which indexes that are most used for reads most fragmented? PERFORMANCE Which indexes have the most page splits? Which indexes have the most latching | locking time? Which indexes have the highest average latching | locking time per user interaction? Which indexes have the most table lock promotion attempts | successes? Are there any missing indexes that could help reduce latch | lock | IO latch waits? INFORMATIONAL What indexes are on (this) table? This is where we list the questions from the scripts and the math for what objects are used to answer.

CONTACT POINTS thesqlagentman.com SQLCruise.com tim@sqlcruise.com @sqlagentman @sqlcruise