Sql-server – Managing SQL Server MDF and LDF file size

sql server

I am new to SQL Server and don't fully understand its architecture. I've looked around, Googled, asked around but found no simple (understandable) answer to the problem. I'm not even sure if it is problem in technical terms or just the default behavior, but in terms of my business operation, it is a big problem.

I have acquired SQL Server 2008 R2 [from the developer who doesn't work here anymore], with a database of physical storage size of 2 TB. I've created a database, say TEST with

  • TEST.mdf default at 10 MB, 10% growth and max size: unlimited. There are 40 files comprising the TEST.mdf file say TEST_part01 through TEST_part40 with same configuration as TEST.mdf.

  • The log file – TEST_log.ldf file also has same configuration as TEST.mdf

  • The database handles millions of rows in daily basis, with lots and lots of insert, delete, update, drop etc. operations.

  • I am running out of space. While trying to shrink the database, I saw that the TEST.mdf could be shrunk by 41% and TEST_log.mdf by 99%.

Questions

  1. Is 41% and 99% of recoverable space actually taken by garbage, un-used data? If so can I selectively remove/purge (if not all than most of ) the 41% and 99% of data?

  2. Is there any temporary or otherwise structure/objects created by the SQL Server itself, which I can safely delete/purge?

Best Answer

If you just acquired an instance of SQL Server from someone, I would first ask have you gone over the instance configuration and all to understand how the previous person had it configured?

I would suggest taking a look at Brent Ozar's sp_BLITZ script. It is a stored procedure that will collect some good information for you on your instance configuration and give you a good overview of what it sees. I would read over Brent's blog on this script in detail before ever running this on your server, FULLY understand what it is doing.

Regarding your database, are you running out of disk storage or database storage? How much free space does the database contain? I would first understand the architecture of the files before I start making changes. A good article to read on file management is from SQLSkills.com here.

Just my $0.02...