Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

when to defragment indexes Expand / Collapse
Author
Message
Posted Monday, January 28, 2013 9:11 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 22, 2013 2:39 AM
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
Post #1412494
Posted Monday, January 28, 2013 9:28 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, May 25, 2014 10:09 AM
Points: 283, Visits: 1,114
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
Post #1412504
Posted Monday, January 28, 2013 10:24 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 22, 2013 2:39 AM
Points: 6, Visits: 27
Thanks Richard,
Just the info I was looking for
Post #1412544
Posted Monday, January 28, 2013 10:32 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, July 14, 2014 2:06 PM
Points: 3,865, Visits: 7,130
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"
Post #1412548
Posted Monday, January 28, 2013 5:11 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: 2 days ago @ 12:28 PM
Points: 185, Visits: 918
ugo boy (1/28/2013)
I mean, if there are no searches done on the table
then you should DROP these indexes.



Alex Suprun
Post #1412708
Posted Monday, January 28, 2013 6:11 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, July 14, 2014 2:06 PM
Points: 3,865, Visits: 7,130
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"
Post #1412715
Posted Tuesday, January 29, 2013 1:00 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, July 21, 2014 6:24 AM
Points: 3,537, Visits: 2,647
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/
Post #1412794
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse