Auto Close and Auto Shrink - Just Don't

  • Comments posted to this topic are about the content posted at

  • Another problem with autoshrink is simplf that it moves data. You might work very hard to make sure your tables, indexes, etc., get built contiguously only to have autoshrink make mincemeat of all your hard work. Like the author says: no thanks.

    One possible exception: a sandbox / desktop server where space really *might* matter that much and performance might *not*.

  • I agree regarding auto close, but disagree regarding auto shrink. Reason: I have many databases to deal with some of which grow their logs very fast eating up valuable disk space. Auto shrink ensures that unused space is returned to the pool. I feel that the CPU performance hit is acceptable compared to the problems ensuing when we run out of disk space.

  • Dave, I agree that leaving space tied up may not be a good thing, but wouldn't you consider it better to either do after hours or at a time when you knew it would least impact performance?


  • Just Say No. Control when the shrinking takes place if you need to worry about it. Though I'd say if you are tight on disk space, you've got other issues.

    Steve Jones

  • Hi there

    Experience tells me to manage it yourself in terms of shrinking (when it happens, what is going on and sync it with other jobs that may be going on). The trick to watch a little more carefully I believe is your growth settings and not chewing space that perhaps wont be used for sometime. Managing transaction log space utilisation is another tricky one, especially if you have the occasional very large job that blows out the log size.

    Btw, I havent measured the performance hit whilst files are expanding or shrinking during heavy IO... I like to monitor growth and get a feel for this to ensure files cater for the expansion (reserved space) without sqlserver working to grab more space.

    The close option is a silly one and I never set it. I have come across some issues of connections locking up and blocking because of it. Its probably been resolved between versions etc etc but I cant see any logical value in it.


    Chris K

    Chris Kempster
    Author of "SQL Server Backup, Recovery & Troubleshooting"
    Author of "SQL Server 2k for the Oracle DBA"

  • With the whole shrinking we use truncating of the transaction log as well.

    At the end of the day(during normal at hours-middle of the night) we do all the shrinking etc, but we truncate the transaction log. This saves alot of space for backup purpose.

    Is this bad good or ugly.


  • I would shrink during a quiet time (if there is any) for your DBMS, get a feel for the average times taken and move the times around from there.

    As for the truncation of the logs, so long as you dont require point in time (PTR) recovery, then its a no issue.



    Chris Kempster
    Author of "SQL Server Backup, Recovery & Troubleshooting"
    Author of "SQL Server 2k for the Oracle DBA"

  • RE truncating the Logs - if you're going to go to the effort of truncating 'em - why not just set the database to simple logging and be done with it?

    RE Dave comment's about AutoShrink - Dave - can you not set up an alert+job to backup the transaction log when it get's to (say) 80% capacity? That way you don't have the CPU hit of a log file that is constantly growing and shrinking...

  • For production system, I agree, just say no. Manage space usage based on the business needs (slow time) and don't rely on Auto Shrink.

    I've found some "production" systems such as Crystal Reports that use MSDE with auto close enabled. so review every install, and do an inventory of all your production system if you need to.

    What's the business problem you're trying to solve?

  • I don't know that it's as simple as just changing it to simple mode. I run on average about 200 db's, all fully logged. On any given day maybe 25% are really being used. I run log backups 4 times a day, but I run a second job that backs up any log over 50mb (arbitrary, pick a # you like) and then shrinks the log. This gives me a usage based backup, plus keeps disk usage in check. The time it takes to shrink a log is pretty small compared with a db backup. Switching to simple doesn't alleviate the problem of space usage, one big transaction can balloon up the file size way beyond what it "normally" is.


  • I agree that Auto Close is a silly option. It potentially causes more headaches than it is worth. Rdb (purchased by Oracle several years ago) has the same goofy feature.

    On the other hand, we use Auto Shrink at our site. We have about 40 SQL Server machines with roughly 800 databases spread across them. Most of our Production servers are beefy machines (most with 4 CPUs, some with 8 CPUs), and many of our larger Production databases reside on (high-priced) EMC disk storage. Auto Shrink helps us to conserve disk space. So far, I have only noticed Auto Shrink causing a performance problem on one database in particular--that SQL 7.0 database is heavily updated throughout the day, and we disabled Auto Shrink for it. I haven't noticed any Auto Shrink problems with SQL 2000 at this point.

    As long as you recognize the potential problems that Auto Shrink can create, I don't see any problem with trying the feature. If it causes problems, you can always turn it off. Auto Shrink has certainly stopped a lot of disk space-related phone calls on our Development boxes.

    Just my 2 cents... Another 48 will buy you a (small) cup of coffee. 😉

  • By the way, several people alluded to shrinking the databases during off hours. Would anyone care to post the syntax they use?


  • On the databases I have AutoClose off. It's one of those really bright ideas that no one wants.

    Autoshrink is off because I found it twice trying to shrink itself during a very heavy I/O time (which added to the length of time for the process).

    I just use DBCC SHRINKFILE(table, size).


    Quand on parle du loup, on en voit la queue

  • Having read the advice regarding auto_shrink, I checked our database and found that several did indeed have that option on.

    Rather than simply turning it off (we have gobs of space available, but I don't know that I want to let things grow without bounds), I decided to see if SQL Server 2000 provided a simple way to do this. Surprise, surprise, you can set a time to shrink in your maintenance plan. We'll be doing weekly shrinks (once the database grows to twice its current size, that is).

    R David Francis

Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic. Login to reply