1

Below is what I did:

  1. Created database in simple recovery mode.
  2. Created table.
  3. Began tran and inserted so many rows to exceed size of the log file.
  4. Committed the transaction.

Before step 4 I noticed that log file grew, which confused me. Why did that happen?

According to MSDN:

For each logical write, a transaction log record is inserted in the log cache that records the modification.

And then:

Log records are written to disk when the transactions are committed.

So how do you explain the fact that the log file is growing when the data is being inserted, even when a transaction is not committed?

As I understand, uncommitted log records should be stored in the log buffer, not on disk.

8

Transaction log records are flushed as log buffers become full, which is why you observed growth before the final COMMIT. The buffer is also flushed when a durable transaction is committed, which guarantees durability.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.