I'm doing an index report on my MS SQL 2008 database (Right click database -> Reports -> Index Usage Statistics)
It tells me that one of my indexes uses: 88 user seeks 0 user scans 6,134,141 user updates
Can someone explain to me:
I think in this case the cost of maintaining the index is not worth it.
When you create index, statistics are created with 100% of data. Running update statistics with default setting will overwrite it with sample. As you data change (insert/update/delete) you will need to periodically update statistics to make sure your changes are reflected in your statistics.
dm_db_index_usage_stats DMV result helps to decide if we need to remove that index or replace it with more optimal one.
What are SQL Server index statistics? Index statistics contain information about the distribution of index key values. By distribution, I mean the number of rows associated with each key value. SQL Server uses this information to determine what kind of execution plan to use when processing a query.
Snipit from the article (definitely give it a read though):
Scans
An index scan is a complete read of all of the leaf pages in the index. When an index scan is done on the clustered index, it’s a table scan in all but name.
When an index scan is done by the query processor, it is always a full read of all of the leaf pages in the index, regardless of whether all of the rows are returned. It is never a partial scan.
A scan does not only involve reading the leaf levels of the index, the higher level pages are also read as part of the index scan.
Seeks
An index seek is an operation where SQL uses the b-tree structure to locate either a specific value or the beginning of a range of value. For an index seek to be possible, there must be a SARGable3 predicate specified in the query and a matching (or partially matching) index. A matching index is one where the query predicate used a left-based subset of the index columns. This will be examined in much greater detail in a part 3 of this series.
The seek operation is evaluated starting at the root page. Using the rows in the root page, the query processor will locate which page in the next lower level of the index contains the 1st row that is being searched for. It will then read that page. If that is the leaf level of the index, the seek ends there. If it is not the leaf then the query processor again identifies which page in the next lower level contains the specified value. This process continues until the leaf level is reached.
Once the query processor has located the leaf page containing either the specified key value or the beginning of the specified range of key values then it reads along the leaf pages until all rows that match the predicate have been returned.
One important point to note up front: the index usage statistics are reset every time the database is started. So, it's hard to evaluate your 88 seeks without knowing when you last restarted. 88 seeks in the last hour is quite different than 88 seeks in the last month.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With