In SQL Server, the Wal of the log is used to guarantee the persistence of relational databases, but because of the characteristics of the hard disk, it is not possible to write each log directly to disk once, so the log is cached to a certain amount of data before it is written to disk. This part of the generated, but not written to disk log, is called the in-flight log.
In SQL Server, the size of the in-flight log depends on two factors, and according to Paul Randal, the in-flight log cannot exceed 60K, so the maximum in-flight log is 60K, in addition, If the in-flight log does not reach 60K, if a commit or rollback occurs, the disk is written directly. So the log minimum is 512 bytes, the maximum is 60K, and it grows in 512 bytes. Let's take a look at the example below.
Let's start by creating a simple table that loops into 10W of data, which generates a lot of logs, as shown in Listing 1:
Begin TRAN
DECLARE @i INTEGER
SET @i = 0 while
(@i < 100000)
begin
Inserts
into number VAL UES (@i)
SET @i = @i + 1
end
CHECKPOINT
COMMIT
Code Listing 1. Statements that generate a large number of logs
The database I start with a 5M log and increment in 5M, and the above statement causes the log to grow automatically, as shown in Figure 1.
Figure 1 The corresponding 6 log growth