Dynamics NAV and SQL Server 2005 rarely used indexes

In order to tune-up your Dynamics NAV database performances, I've always written that working on indexes is one of the first steps and using the correct index will permit you to speed up lots of operations.

But what about rarely-used indexes? Dynamics NAV comes with lots of indexes on the standard tables, but many of them are not often used. Also on custom tables I often see that developers place lots of indexes that are unuseful.

Because the cost of these indexes is incurred during maintenance (e.g. insert, update, and delete operations), the write costs of rarely-used indexes may outweigh the benefits.

So, how you can detect them?

A good way to monitor your Dynamics NAV database (but in general your SQL Server 2005 database) is to run this T-SQL script:

declare @dbid int
select @dbid = db_id()
select objectname=object_name(s.object_id), s.object_id
, indexname=i.name, i.index_id
, user_seeks, user_scans, user_lookups, user_updates
from sys.dm_db_index_usage_stats s,
sys.indexes i
where database_id = @dbid
and objectproperty(s.object_id,'IsUserTable') = 1
and i.object_id = s.object_id
and i.index_id = s.index_id
order by (user_seeks + user_scans + user_lookups + user_updates) asc

Indexes with a little value of these parameters are indexes that can be deleted (no benefits by having them).

Print | posted on Thursday, January 25, 2007 1:31 PM

Comments on this post

# re: Dynamics NAV and SQL Server 2005 rarely used indexes

Requesting Gravatar...
Hey
The code doesn't see m to work. It shows only blank. The database was used.

The sys.dm_db_index_usage_stats ...where is it?
Left by ovidiu on Feb 21, 2007 8:17 AM

# re: Dynamics NAV and SQL Server 2005 rarely used indexes

Requesting Gravatar...
Are you using SQL 2005? sys.dm_db_index_usage_stats is one of the new dynamic management views (DMV) introduced on SQL Server 2005.
DMVs permits you to look at the internal workings of SQL Server using TSQL and they allow you an easy method for monitoring what SQL Server is doing and how it is performing.
Left by on Feb 21, 2007 7:46 PM

# re: Dynamics NAV and SQL Server 2005 rarely used indexes

Requesting Gravatar...
Sorry I've not signed the answer... but it was mine
Left by Stefano Demiliani on Feb 21, 2007 7:47 PM

# re: Dynamics NAV and SQL Server 2005 rarely used indexes

Requesting Gravatar...

hi
thnks for ur site , it helps me lot for my profession. now i got an idea to use dynamics and also simplesity with it. it works wonderful, keep on trying siplisity of dyanamic. am also try to do same.

by bye
Regards
Satish.A
Left by satish on Jun 16, 2007 8:43 AM

Your comment:

 (will show your gravatar)
 
Please add 5 and 4 and type the answer here: