Auto shrink is just pure evil

Published On: 2009-10-29By:

If you don’t agree with the above statement please keep reading.  I’m write, and it’s important, I promise.

In order for the auto-shrink feature to be really effective it has to move data from the end of the file to the middle/front of the file so that it can chop off the tail end of the database file.  This causes extra load to be placed on the disk, and on the CPU as it is identifying the data pages which can be moved, then moves them.

It also causes extra fragmentation to happen within the database as the shrink operation does not preserve the fragmentation state of the indexes within the database.  Because of this the worst time to shrink a database is write after the indexes have been rebuilt.  Because of the extra space that is needed to rebuild indexes this is probably also the most common time to shrink a database on a regular basis.

My favorite reason to not shrink a database is listed directly in Books OnLine under the “Shrinking a Database” heading.  Under the Best Practices topic it says “Unless you have a specific requirement, do not set the AUTO_SHRINK database option to ON.”.

So go and turn your AUTO_SHRINK settings to off like they should be and quit worrying if the hard drive icon in the My Computer window shows that it’s full.  Worry about about how much free space is within the database files, not the free space on the disk.   Fill the disk already.  It’s fun, and all the cool kids are doing it.

Denny


Contact the Author | Contact DCAC

2 responses to “Auto shrink is just pure evil”

  1. BrianTkatch says:

    Interesting note about fragmentation. Thanx!

    Typo: write
    should be “right”

    Twice even.

  2. Unclebiguns says:

    Makes you wonder why it is still in available in the product.

Video

Globally Recognized Expertise

As Microsoft MVP’s and Partners as well as VMware experts, we are summoned by companies all over the world to fine-tune and problem-solve the most difficult architecture, infrastructure and network challenges.

And sometimes we’re asked to share what we did, at events like Microsoft’s PASS Summit 2015.

Awards & Certifications

Microsoft Partner       Insights Sccess Award    Technology Headlines Award    Golden Bridge Gold Award    CIO Review Top 20 Azure Solutions Providers    VMWare Partner
Microsoft Certified Master    Microsoft MVP
Share via