SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


when to defragment indexes


when to defragment indexes

Author
Message
ugo boy
ugo boy
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 27
Hi All,
I understand that indexes need to be defragmented when they get fragmented,
however must one defragment an index even if it is 100% fragmented?
I mean, if there are no searches done on the table, then it doesn't matter if it is 100% fragmented (does it?)
but if searches are constantly done on the table then it would make sense to defrag the table so as to improve the search performance.
Now comes my next question....
How can I find out which tables are constantly searched and which ones are not
Thanks
UgoBoy
Richard Fryar
Richard Fryar
SSC-Addicted
SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)

Group: General Forum Members
Points: 489 Visits: 1172
The effect of fragmentation depends on whether in order scans are being performed - common in reporting databases - and also on the size. There is no real benefit with less than a few hundred pages, unless you have a tiny amount of RAM - and then you've got more serious problems.

To see which indexes are being scanned have a look at sys.dm_db_index_operational_stats


Check Your SQL Servers Quickly and Easily
www.sqlcopilot.com
ugo boy
ugo boy
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 27
Thanks Richard,
Just the info I was looking for
MyDoggieJessie
MyDoggieJessie
SSCertifiable
SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)

Group: General Forum Members
Points: 6668 Visits: 7394
It can also be quite helpful to look at your cached execution plans to see which queries/procedures have inadequate query plans, this can be found by running the code below
SELECT 
DB_NAME(st .dbid),
[cp] .[refcounts],
[cp] .[usecounts],
[cp] .[objtype], --,[st].[dbid]
--,[st].[objectid]
OBJECT_NAME(st .objectid),
[st] .[text],
[qp] .[query_plan]
FROM sys .dm_exec_cached_plans AS cp
CROSS APPLY sys. dm_exec_sql_text(cp .plan_handle) AS st
CROSS APPLY sys. dm_exec_query_plan(cp .plan_handle) AS qp
WHERE [st]. [dbid] IN (7, 12,13 ,15)
AND [st].[text] NOT LIKE '%sp_M%'
AND [st]. [text] NOT LIKE '%sys%'
--AND cp.objtype = 'adhoc'
ORDER BY usecounts DESC

If tables aren't being used by any query(ies), then having indexes on them is really overkill and ends up just consuming valuable server resources...not to mention adds extra time to any indexing strategy you may have in place.

______________________________________________________________________________
"Never argue with an idiot; They'll drag you down to their level and beat you with experience" ;-)
Alexander Suprun
Alexander Suprun
Mr or Mrs. 500
Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)Mr or Mrs. 500 (513 reputation)

Group: General Forum Members
Points: 513 Visits: 1516
ugo boy (1/28/2013)
I mean, if there are no searches done on the table
then you should DROP these indexes.


Alex Suprun
MyDoggieJessie
MyDoggieJessie
SSCertifiable
SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)

Group: General Forum Members
Points: 6668 Visits: 7394
Alexander Suprun (1/28/2013)
ugo boy (1/28/2013)
I mean, if there are no searches done on the table
then you should DROP these indexes.
Keep in mind these statistics are cumulative and only show information since the last time the MSSQL service was started. If you recently restarted the service and check this DMV, you may find many indexes that don't appear to be used...so be careful deleting them without first checking whether they're really needed or not.

______________________________________________________________________________
"Never argue with an idiot; They'll drag you down to their level and beat you with experience" ;-)
sqlnaive
sqlnaive
SSCarpal Tunnel
SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)

Group: General Forum Members
Points: 4277 Visits: 2774
Hi ugo_boy
These links might help:
http://technet.microsoft.com/en-us/library/ms189858.aspx
http://www.mssqltips.com/sqlservertip/1852/sql-server-2005-index-best-practices/
http://blog.sqlauthority.com/2008/03/27/sql-server-2005-find-index-fragmentation-details-slow-index-performance/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search