You are here
Home > SQL > Shrink Bloated Development Databases – Save Precious Space

Shrink Bloated Development Databases – Save Precious Space

Shrink Bloated Development Databases – Last night I noticed that the space on my C drive was running slightly low. When this happens, I usually go and look in the temp folder to see what unnecessary space hogs are hiding there. After clearing this folder I realised that the amount of data removed from this folder didn’t make much of a difference. I then went hunting. Using a very nifty tool called WinDirStat, I found the problem files. It turns out that some of my development databases were absolutely huge. The LDF files were several gigs in size. Here is what I did to save a little bit of space.

Shrink Bloated Development Databases

Many times I use a copy of a customer’s database in order to test applications with ‘real world’ data. I usually create a database from a backup I’m sent. This backup would then often contain very large LDF files. In a production environment you might need to use a full recovery mode for your SQL Database. Since I am only using this for testing, I don’t need to recover anything and can modify the recovery model with confidence. As you can see below, the LDF file was 36 Gig in size.

Shrink Bloated Development Databases

To shrink this LDF file, go to the object explorer in SQL Server Management Studio and right click your development database. From the context menu, select properties. Under the Options group, you will see the recovery model. If your LDF file is big, you can expect this setting to be set to ‘Full.

Shrink Bloated Development Databases

As I mentioned above, I’m not concerned with recovering any data so I can go ahead and set the recovery model for this development database to ‘Simple’.

Shrink Bloated Development Databases

After clicking on OK, right click the database again and select Tasks -> Shrink -> Database.

Shrink Bloated Development Databases

On the following screen, check the option to reorganize files and leave the maximum free space setting to 0%. Click on OK. What follows depends on the size of your LDF file. The larger your LDF file is, the longer the shrinking process will take.

Shrink Bloated Development Databases

When the process completes, head on over to your LFD file again and see how much space you have saved.

Shrink Bloated Development Databases

This quick and nifty trick can save you loads of space on a development machine. If you work with many different databases on your development machine, chances are there are a few large LDF files lurking there.

MSDN

Dirk Strauss
Dirk is a Software Developer and Microsoft MVP from South Africa. He loves all things Technology and is slightly addicted to Twitter and Jimi Hendrix. Apart from writing code, he also enjoys writing human readable articles. "I love sharing knowledge and connecting with people from around the world. It's the diversity that makes life so beautiful." Dirk feels very strongly that pizza is simply not complete without Tabasco, that you can never have too much garlic, and that cooking the perfect steak is an art he has yet to master.

Similar Articles

Top