Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset SQL Server Index usage

I use below query to analyze usage of index in SQL Server.

SELECT * 
FROM sys.dm_db_index_usage_stats A
WHERE A.database_id = DB_ID()

How can reset all data from this system table?

like image 358
mehdi lotfi Avatar asked Jul 06 '13 04:07

mehdi lotfi


People also ask

How to reset the index usage statistics?

Index usage statistics keep track of things like seeks and scans from SELECT queries. They are not persisted and get reset on restart of sql server. These statistics also get reset if the underlying index is rebuilt "ALTER INDEX ... REBUILD", but not with "ALTER INDEX ... REORG" As said, you can't reset it manually.

Do Index statistics get reset on restart of SQL Server?

They are not persisted and get reset on restart of sql server. These statistics also get reset if the underlying index is rebuilt "ALTER INDEX ... REBUILD", but not with "ALTER INDEX ...

Where can I find index usage statistics in SQL Server?

Usage statistics: These are found in sys.dm_db_index_usage_stats. Index usage statistics keep track of things like seeks and scans from SELECT queries. They are not persisted and get reset on restart of sql server.

What happened to alter index rebuild in SQL Server?

As of SQL Server 2012, suddenly all that information started getting reset whenever anyone ran ALTER INDEX REBUILD. Confusingly for users, this only happened with one specific command: REBUILD.


1 Answers

What do you mean by reset .. do you want to reset the index usage statistics in the table?

Taken from Here

Usage statistics: These are found in sys.dm_db_index_usage_stats. Index usage statistics keep track of things like seeks and scans from SELECT queries. They are not persisted and get reset on restart of sql server. These statistics also get reset if the underlying index is rebuilt "ALTER INDEX ... REBUILD", but not with "ALTER INDEX ... REORG"

As said, you can't reset it manually. Take a look at this post which certainly says the same

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/08eb7b79-64a3-4475-bfc3-69715aec8381/resetting-dmdbindexusagestats-without-restarting-or-detaching-a-database

like image 80
Rahul Avatar answered Sep 22 '22 11:09

Rahul