Sample Header Ad - 728x90

What are good metrics for determining the usefullness/impact of an index in a SQL server database?

0 votes
1 answer
68 views
**Background** I'm reviewing a database currently where someone applied indexes to almost everything in the database. Since we are now experiencing performance issues related to updating records, I'm trying to determine which indexes should be kept and which should be removed. Note: I do not have access to the source code that makes requests to the database, so I do not have a complete picture as to all the requests being made to the database. **Sample Data** Using the query below found in the first answer in the post List of all index & index columns in SQL Server DB use UAT_PLUS go SELECT TableName = t.name ,IndexName = ind.name ,IndexId = ind.index_id ,ColumnId = ic.index_column_id ,ColumnName = col.name --,ind.* --,ic.* --,col.* FROM sys.indexes ind INNER JOIN sys.index_columns ic ON ind.object_id = ic.object_id and ind.index_id = ic.index_id INNER JOIN sys.columns col ON ic.object_id = col.object_id and ic.column_id = col.column_id INNER JOIN sys.tables t ON ind.object_id = t.object_id WHERE ind.is_primary_key = 0 AND ind.is_unique = 0 AND ind.is_unique_constraint = 0 AND t.is_ms_shipped = 0 ORDER BY t.name, ind.name, ind.index_id, ic.is_included_column, ic.key_ordinal; I get results similar to (This is an actual table in the database just with some values generalized) TableName | IndexName | IndexId | ColumnId | ColumnName -- | -- | -- | -- | -- TABLE_A | Index_1 | 183 | 1 | Col_1 TABLE_A | Index_1 | 183 | 2 | Col_2 TABLE_A | Index_1 | 183 | 3 | Col_3 TABLE_A | Index_1 | 183 | 4 | Col_4 TABLE_A | Index_1 | 183 | 5 | Col_5 TABLE_A | Index_2 | 184 | 1 | Col_1 TABLE_A | Index_2 | 184 | 2 | Col_2 TABLE_A | Index_2 | 184 | 3 | Col_3 TABLE_A | Index_2 | 184 | 4 | Col_4 TABLE_A | Index_2 | 184 | 5 | Col_6 TABLE_A | Index_2 | 184 | 6 | Col_5 TABLE_A | Index_2 | 184 | 7 | Col_7 TABLE_A | Index_3 | 4 | 1 | Col_2 TABLE_A | Index_3 | 4 | 2 | Col_4 TABLE_A | Index_4 | 3 | 1 | Col_2 TABLE_A | Index_4 | 3 | 2 | Col_3 TABLE_A | Index_5 | 2 | 1 | Col_2 TABLE_A | Index_6 | 9 | 1 | Col_4 TABLE_A | Index_7 | 10 | 1 | Col_8 TABLE_A | Index_8 | 11 | 1 | Col_9 TABLE_A | Index_9 | 6 | 1 | Col_2 TABLE_A | Index_9 | 6 | 2 | Col_10 TABLE_A | Index_9 | 6 | 3 | Col_3 TABLE_A | Index_9 | 6 | 4 | Col_4 TABLE_A | Index_10 | 5 | 1 | Col_2 TABLE_A | Index_10 | 5 | 2 | Col_4 TABLE_A | Index_10 | 5 | 3 | Col_3 TABLE_A | Index_11 | 163 | 1 | Col_3 TABLE_A | Index_11 | 163 | 2 | Col_10 TABLE_A | Index_12 | 8 | 1 | Col_11 TABLE_A | Index_13 | 15 | 1 | Col_12 TABLE_A | Index_14 | 18 | 1 | Col_13 TABLE_A | Index_15 | 19 | 1 | Col_14 TABLE_A | Index_16 | 14 | 1 | Col_15 TABLE_A | Index_17 | 13 | 1 | Col_16 TABLE_A | Index_18 | 12 | 1 | Col_17 TABLE_A | Index_19 | 17 | 1 | Col_18 TABLE_A | Index_20 | 16 | 1 | Col_19 TABLE_A | Index_21 | 182 | 1 | Col_1 TABLE_A | Index_22 | 7 | 1 | Col_3 TABLE_A | Index_23 | 181 | 1 | Col_4 TABLE_A | Index_23 | 181 | 2 | Col_3 TABLE_A | Index_23 | 181 | 3 | Col_1 TABLE_A | Index_23 | 181 | 4 | Col_2 TABLE_A | Index_24 | 178 | 1 | Col_1 TABLE_A | Index_24 | 178 | 2 | Col_3 TABLE_A | Index_24 | 178 | 3 | Col_2 TABLE_A | Index_24 | 178 | 4 | Col_4 TABLE_A | Index_25 | 180 | 1 | Col_3 TABLE_A | Index_25 | 180 | 2 | Col_1 TABLE_A | Index_25 | 180 | 3 | Col_2 TABLE_A | Index_25 | 180 | 4 | Col_6 TABLE_A | Index_25 | 180 | 5 | Col_4 TABLE_A | Index_25 | 180 | 6 | Col_7 **Question** What are good metrics and tools that I can use to determine which indexes are useful and which are just causing bloat?
Asked by Tolure (111 rep)
Nov 23, 2023, 05:36 PM
Last activity: Nov 24, 2023, 01:25 AM