Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Indices

Posted on 2012-03-26
7
Medium Priority
?
441 Views
Last Modified: 2012-03-27
We have a large table that is heavily-indexed and I am convinced some of the indices are no longer in use.

Does SQL offer any way to find out when the last time an index was accessed or other means to see how often it is used?

Thanks.
0
Comment
Question by:dthansen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 25

Accepted Solution

by:
TempDBA earned 400 total points
ID: 37769738
The following link will help you. If the number of seeks + lookups are very few, you shouldn't bother about keeping and maintaining it. You can easily drop it.
http://blog.sqlauthority.com/2008/10/03/sql-server-2008-find-if-index-is-being-used-in-database/
0
 
LVL 9

Assisted Solution

by:keyu
keyu earned 400 total points
ID: 37769955
0
 
LVL 15

Assisted Solution

by:Deepak Chauhan
Deepak Chauhan earned 400 total points
ID: 37770241
Hi,
Use this script to find out index usage.. hope so it is usable for u...


SELECT DISTINCT OBJECT_NAME(sis.OBJECT_ID) TableName, si.name AS IndexName, sc.Name AS ColumnName,
sic.Index_ID, sis.user_seeks, sis.user_scans, sis.user_lookups, sis.user_updates
FROM sys.dm_db_index_usage_stats sis
INNER JOIN sys.indexes si ON sis.OBJECT_ID = si.OBJECT_ID AND sis.Index_ID = si.Index_ID
INNER JOIN sys.index_columns sic ON sis.OBJECT_ID = sic.OBJECT_ID AND sic.Index_ID = si.Index_ID
INNER JOIN sys.columns sc ON sis.OBJECT_ID = sc.OBJECT_ID AND sic.Column_ID = sc.Column_ID
WHERE sis.Database_ID = DB_ID('DatabaseName') AND sis.OBJECT_ID = OBJECT_ID('TableName');
GO
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 25

Assisted Solution

by:jogos
jogos earned 400 total points
ID: 37771014
Be aware that the a information of the DMV's (such as  sys.dm_db_index_usage_stats) is initialized by a restart.  So it's important to know if their content spans a fair period.

Even if an index is not used for 2,5 months it can be crusial for a quarterly or yearly report to run in a normal time-frame.  If so it could be worth to see how that index can be less a pain
- only create it in the period you need it
- less included columns that are updated a regularly
- filtered index (2008) so it's smaller but fit's the query it has to speed up
0
 

Author Comment

by:dthansen
ID: 37771362
Looks good.

I will try these out in our next maintenance window in 2 days.

Thanks,
Dean
0
 
LVL 70

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 400 total points
ID: 37771549
As noted by others, sys.dm_db_index_usage_stats is the key view.


Btw, I would never maintain an index(es) solely for quarterly or *yearly* report.  That seems wrong to me.  

If it only runs that infrequently (ONCE a YEAR!), let it scan the whole table -- 3 times even if it needs to -- rather than maintain all the index rows for a full year.

Or build the index(es) immediately prior to the qtrly / yearly reporting, then *drop them* when done that period rpting.
0
 

Author Closing Comment

by:dthansen
ID: 37773637
We got a chance to review index usage stats during idle time today. Unfortunately, it did not reveal any indices we could get rid of.

Thank you  all for your feedback!

Dean
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question