Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Assessing Internal & External Fragmentation

Author  Topic 

DBADave
Constraint Violating Yak Guru

366 Posts

Posted - 2006-08-24 : 10:46:30
I'm writing a script to automate index defragmentation and trend fragmentation growth. Does my WHERE clause, checking SHOWCONTIG results, look correct.

-- External Fragmentation - Candidates for INDEXDEFRAG and UPDATE STATISTICS
FROM DBCC_SHOWCONTIG
WHERE indexid Not In (0,255) -- Not a Heap and does not contain Text data
AND ((LogicalFrag > 10 and LogicalFrag < 15)
OR (Scandensity < 75 and Scandensity > 60))
AND CountPages > 500

-- External Fragmentation - Candidates for DBREINDEX
FROM DBCC_SHOWCONTIG
WHERE indexid Not In (0,255) -- Not a Heap and does not contain Text data
AND (LogicalFrag > 14 OR Scandensity < 60)
AND CountPages > 500

-- Internal Fragmentation
FROM DBCC_SHOWCONTIG
WHERE indexid > 0 -- Not a Heap
AND indexid < 255 -- Does not contain Text data
AND AvgPageDensity < 76
AND CountPages > 100 -- More then 100 Pages

Thanks, Dave
   

- Advertisement -