Presentation is loading. Please wait.

Presentation is loading. Please wait.

How Good Is Your Indexing Strategy?

Similar presentations


Presentation on theme: "How Good Is Your Indexing Strategy?"— Presentation transcript:

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

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

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

4 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

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

6 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

7 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

8 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

9 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

10 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

11 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

12 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

13 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

14 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

15 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

16 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

17 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

18 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.

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


Download ppt "How Good Is Your Indexing Strategy?"

Similar presentations


Ads by Google