Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

When SQL Server database in a SIMPLE mode, you don't have to care about the transaction log bakcups. But in a SIMPLE mode, the transaction log seems to grow as it does in FULL mode. Does is truncate automagically at some time point? Or do I have to truncate/shrink it manually?

3 Answers
3

It will truncate automatically but that is very different to shrink. Truncation reclaims log space for re-use, shrinking physically reduces the file size to release space back to the OS. If your log has grown to its current size its likely that it will grow again if you shrink it.

I'd suggest getting a handle on what typical and maximum log usage is for your system. The query below (not mine, boosted from Glen Berrys DMV scripts) could be run manually or you could capture the output to a table via an agent job. If you log it to a table for a week or so you'll get a picture of typical usage and more importantly, when a process is causing the log to grow beyond what you expect.

If log records were never deleted from the transaction log, it would
eventually fill all the disk space that is available to the physical
log files. Log truncation automatically frees space in the logical log
for reuse by the transaction log.

the contradiction is a result of what it means to "truncate". for some, that means "cleared", for others it means "make smaller", and it is and endless source of confusion for many.
–
SQLRockstarOct 26 '11 at 21:27

As previously mentioned, no it will not automatically shrink itself. It will clean up some garbage however.

The reason being is that in the full recovery model you are telling SQL that you want to do tlog backups for point in time recovery, thus it keeps a record of all transactions made against a database.

Since you are telling it you want point in time recovery you need to do full backups and tlog backups. As you complete your tlog backups it will flush the contents of the log (besides the tail end) and start over.

It may help if you think of these files as containers.

My suggestion is that if the tlogs have become large and unmangable, cut a full backup. Switch to the SIMPLE recover model and SHRINK the tlog file. Switch back to the full recovery model and preform fragmentation maintenance. Like others have posted this is not the best of practices and will lead to high levels of fragmentation.

my comment was intended to be a prompt for you to edit your answer. As it stands, you are suggesting that after switching back to FULL you should run index rebuild/reorganise which will of course cause the log to grow again. I don't see how this fits the question, nor why you see it as part of log maintenance.
–
Mark Storey-SmithNov 4 '11 at 6:29

It isn't apart of log maintenance. How do you maintain your T Logs? You back them up. They are containers that grow when they get close to capacity. I was instructing the OP on one of the ways they could recover from improper log management leading to large drive usage.
–
RMacyNov 8 '11 at 1:43