question

Wilfred van Dijk avatar image
Wilfred van Dijk asked

perc logfile not reduced after logbackup

Hi, I developed a mechanism which executes a logbackup if the size is above a treshold. I use DBCC SQLPERF(LOGSPACE) to calculate the size of being used. After a logbackup I assume the perc_used is reduced (at least for the committed part). However, this is not the case for some (sharepoint) databases and there are NO active transactions. As a result, I get a lot of very small logbackups. 1) Does somebody have an explanation for this? 2) Is there a way to calculate the committed size of a logbackup?
backupadministration
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Grant Fritchey avatar image
Grant Fritchey answered
In general, you should be doing log backups on a regular basis aimed at recovery of your data, not at maintaing the size of the log file itself. If you don't need point in time recovery, set the database to simple and then you don't have to worry about the log backups any more. As to the issue, the way the log gets written, the last entries could be at the very end of the file. So even though you do a backup, you've only removed the earlier entries which are earlier in the file. It won't move those from the end. If you were to issue another checkpoint and then do a backup, likely you'll get to shrink the file. By the way, shrinking the file over and over again creates massive fragmentation. Also, assuming you've got auto-grow turned on for this log, you're probably looking at ever increasing numbers of VLFs. I'd check that. [Michele Ufford][1] has a script for looking at it. [1]: http://www.google.com/url?sa=t&rct=j&q=&esrc=s&frm=1&source=web&cd=4&ved=0CD4QFjAD&url=http%3A%2F%2Fsqlfool.com%2F2010%2F06%2Fcheck-vlf-counts%2F&ei=RLQvT9SjMoTy0gGa-LnxCg&usg=AFQjCNG5J2QJTafYp6_O3pu9eIHUep_4-Q&sig2=zLUPiBp1buDPbv7JSMZG-g
3 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Forgot to say this mechanism is an addition the the regular logbackup. It's just a mechanism to prevent large logfiles due to some user actions (like adding a lot of documents in a sharepoint database)
0 Likes 0 ·
Sounds interesting. Can you please give more details about the mechanism? Like frequency etc?
0 Likes 0 ·
1. load the output of DBCC SQLPERF(logspace) into a table 2. calculate the used amount of the logspace (logsize/100) * perc_used 3. if this is above a treshold or the last logbackup is older than ## minutes create a one-time job which executes the backup log statement. This job wil be deleted when it's finished (logfile is not shrinked) These steps are in another SQL job which runs every 5 minutes
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.