
Signature
Jason Massie
www: http://statisticsio.com
rss: http://feeds.feedburner.com/statisticsio
Note that fragmentation as reported by sys.dm_db_index_physical_stats or
DBCC SHOWCONTIG is not a necessary condition for rebuilding an index.
Ultimately, it depends on the nature of your workload whether fragmentation
may have a material impact of your app's performance. If your app is not
sensitive to index fragmentation, you have an option of just living with
fragmentation.
Linchi
>I would write a custom job that only reindexes indexes that need it like if
>the index is over 5 or 10% fragemented. There is an example on how to do
[quoted text clipped - 37 lines]
>>
>> Victor Desjardins
I copied the example from the BOL and ran it unaltered against an unused test
database. I was expecting that once the job was run, there would be 0%
fragmentation like with a file degragmenter. I copied the entire output
(Executed: ALTER INDEX ... REBUILD) to WinMerge so I could compare the
results after one pass with those from a second. The results, though very
fast (maybe 3 minutes of execution time) were practically unchanged. 528
fragmented tables before. 528 tables after. Maybe one or two would shift
from REBUILD to REORGANIZE but sometimes, it would go the other way.
Eventually, one table did disappear from the list. Is this expected
behaviour and if so, how am I to know that defragmentation has occured?
It seems strange that we would have to resort to a SQL script to do
something that a Maintenance Plan should be capable of accomplishing.
> I would write a custom job that only reindexes indexes that need it like if
> the index is over 5 or 10% fragemented. There is an example on how to do
[quoted text clipped - 35 lines]
> >
> > Victor Desjardins
Andrew J. Kelly - 25 Feb 2008 23:19 GMT
If your table is a HEAP (No clustered index) then you can rebuild it all you
want and the fragmentation will not change one bit. If the index has less
than 8 pages rebuilding is essentially wasted effort as well.

Signature
Andrew J. Kelly SQL MVP
Solid Quality Mentors
>I copied the example from the BOL and ran it unaltered against an unused
>test
[quoted text clipped - 57 lines]
>> >
>> > Victor Desjardins
Ola Hallengren - 17 Mar 2008 01:22 GMT
>I copied the example from the BOL and ran it unaltered against an unused test
database. I was expecting that once the job was run, there would be 0%
fragmentation like with a file degragmenter.
Coruscant, it seems like tables with few pages always report a high level of
fragmentation. It's also so that fragmenation is not a problem in tables with
few pages.
Kalen Delaney has written a blog post about this recently.
http://sqlblog.com/blogs/kalen_delaney/archive/2008/02/28/fragmentation-revisite
d.aspx
>It seems strange that we would have to resort to a SQL script to do something that a Maintenance Plan should be capable of accomplishing.
I have a stored procedure that could help you with this. The stored
procedure does index rebuild online or offline, index reorganization,
statistics update, index reorganization and statistics update or nothing
based on fragmentation level, LOB existence and index size.
http://blog.ola.hallengren.com/blog/_archives/2008/1/1/3440068.html
http://blog.ola.hallengren.com/_attachments/3440068/Documentation.html
http://blog.ola.hallengren.com/_attachments/3440068/IndexOptimize.sql
Ola Hallengren
http://ola.hallengren.com
> I copied the example from the BOL and ran it unaltered against an unused test
> database. I was expecting that once the job was run, there would be 0%
[quoted text clipped - 49 lines]
> > >
> > > Victor Desjardins