Вопрос

I have been tasked with administering some MS SQL Server (Express) databases. My primary DBA experience has been with DB2 LUW and Oracle Database, and I have a hard time understanding the way SQL Server is handling its transaction log.

I have a database set to "full" recovery model and a pre-allocated transaction log file of 100 MB. Using the Windows scheduler, I run daily full backups at 00:00 and log backups every 2 hours, starting at 02:00.

It was my understanding that running the log backups will automatically free up transaction log space, but this does not seem to be the case -- the output of "dbcc sqlperf(logspace)" shows that the "log space used%" figure is continually (if slowly) rising.

It is currently at 5%, so I'm not yet in a state of panic, but I am confused about the way SQL server is doing this.

The TSQL statement I use for full backups:

BACKUP DATABASE [xxx] TO DISK = N'E:\backups\xxx.bak' WITH DESCRIPTION = N'blah', RETAINDAYS = 7, NOFORMAT, NOINIT, NAME = N'blah', NOSKIP, REWIND, NOUNLOAD, STATS = 10, CHECKSUM

The TSQL statement for log backups is:

BACKUP LOG [xxx] TO DISK = N'E:\backups\xxx.trn' WITH DESCRIPTION = N'blah', RETAINDAYS = 7, NOFORMAT, NOINIT, NAME = N'blah', NOSKIP, REWIND, NOUNLOAD, STATS = 10, CHECKSUM

So, what do I have to do in order to free up log space?

Thanks in advance for your input.

Это было полезно?

Решение

dbcc sqlperf(logspace) shows approximate usage of log space. Usually this value is higher (but never lower) than actual free space. This article describes in short why log space used is not set to “0” after log backup: http://support.microsoft.com/kb/281879. So your log space used may rise up to 25% and then fall back to e.g. 5%. You should not worry about increasing log space used value. As soon as you have regular log backups transaction log will have enough free space (except situation when one single transaction will span for 100 Mb of log file which is not very common situation I guess).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top