SQL Server with Mr. Denny

Oct 29 2009   11:00AM GMT

Auto shrink is just pure evil

Denny Cherry Denny Cherry Profile: Denny Cherry

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

2  Comments on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • BrianTkatch
    Interesting note about fragmentation. Thanx! Typo: write should be "right" Twice even.
    0 pointsBadges:
    report
  • Unclebiguns
    Makes you wonder why it is still in available in the product.
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: