0

In SQL Server 2000 - how can we find unused indexes, so that we can drop them.]

I have scripts for 2008 but don't know how to do it in SQL Server 2000.

Please help.

Regards

1
  • 1
    Maybe copy your db in sql server 2008 and use that script to find them,if thats an option.
    – Mihai
    Commented Jan 1, 2014 at 8:12

2 Answers 2

1

The only thing I can recommend is to put your 2000 database on a server with SQL Server 2005 or greater (a development or test server) installed, find the unused indexes with the help of the new DMVs and once you have a list of changes apply them back to the production SQL Server 2000 instance.

Please be aware that SQL Server 2000 is no longer supported and you should move your production processes, if possible, to a later version of SQL Server.

An example query in SQL Server 2012 using the sys.dm_db_index_usage_stats DMV:

SELECT u.*
FROM [sys].[indexes] i
JOIN [sys].[objects] o
ON (i.OBJECT_ID = o.OBJECT_ID)
LEFT JOIN [sys].[dm_db_index_usage_stats] u
ON (i.OBJECT_ID = u.OBJECT_ID)
AND i.[index_id] = u.[index_id]
AND u.[database_id] = DB_ID() --returning the database ID of the current database
WHERE o.[type] <> 'S' --shouldn't be a system base table
AND i.[type_desc] <> 'HEAP'
AND i.[name] NOT LIKE 'PK_%'
AND u.[user_seeks] + u.[user_scans] + u.[user_lookups] = 0
AND u.[last_system_scan] IS NOT NULL
ORDER BY 1 ASC
2
  • 2
    You should mention that you have to point your application or some equivalent workload generation at the new server, preferably representing a full business cycle. Anything less will contain more unused indexes than probably actually happen in production. Commented Jan 1, 2014 at 23:22
  • This is true. I shouldn't have assumed he would know that. Thanks.
    – Troy
    Commented Jan 2, 2014 at 21:46
0

Unused Index information is not exposed in sql 2000 as SQL 2000 and lower versions did not have DMV's.

The only possible way (in sql 2000) is to use a server side trace to see what tables and indexes are used by your queries for the entire business cycle or workload period.

You should plan for an upgrade to higher versions like 2008R2 or 2012 as SQL Server 2000 is now officially unsupported.

2
  • 1
    A trace won't really tell you which indexes are used - you'd have to analyze the execution plans. Commented Jan 2, 2014 at 0:01
  • Good catch and agreed.. Thanks @aaronbertrand ! I can't imagine any other way to find unused indexes on SQL2000.
    – Kin Shah
    Commented Jan 2, 2014 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.