Shrinking files for SQL Server 2005

  • I have a database that has multiple files and separated by filegroups. In the primary group the file has over 70% available free space when I go to Tasks, Shrink, File in SSMS. The other FGs that contain files are also over 50% available free space.

    The question is at this point what is the most efficient way: to release unused space or to reorg pages before releasing unused space or shrink each file to reflect approx. 30 to 40% or some other solution? Any advice would be appreciated.

  • May I ask why are you trying to shrink the files? Are you running low on disk space, or are you just trying to keep things tidy? If the latter and you do not have disk space issues then I recommend you leave things as they are, and forego any shrinking. Here's why: Stop Shrinking Your Database Files. Seriously. Now.[/url]

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • I was concerned about low disk space. But it seems as if I need to watch to see if it stablize. Along with the database the log files grows and I want to set up a regularly schedule job to shrink the log files. Is this a good idea?

  • Kasnut (3/29/2012)


    I was concerned about low disk space. But it seems as if I need to watch to see if it stablize. Along with the database the log files grows and I want to set up a regularly schedule job to shrink the log files. Is this a good idea?

    No. It is a terrible idea. Please read the article from my previous post, as well as all articles it links to.

    If your log files are growing very large something (a bad query most likely) is making them do that. If you shrink the log, it will simply grow again the next time that "something" happens again, only compounding the issue.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Here is another article for you to review, to help you with the fundamentals of what a Transaction Log is, and how to manage it properly: Managing Transaction Logs[/url]

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Shrinking is a bad idea as you'll probably end up with high index fragmentation thus affecting performance. Rebuilding the indexes to improve the performance will increase the size of database.

    :exclamation: "Be brave. Take risks. Nothing can substitute experience." :exclamation:

  • A once-off shrink is fine, as long as it is once-off (run once, not regularly) and you shrink to a size that still leaves enough free space in the files for index rebuilds or data growth.

    70% free space is a little extreme. If you aren't likely to reuse that in 6 or so months from regular data growth, shrink the data files once (to maybe 25% free space) and then rebuild indexes.

    The log file I wouldn't shrink until you know how much log space is needed for regular database activity.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 7 posts - 1 through 6 (of 6 total)

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