All You Need to Know About VLF files:
Every SQL Server database transaction log records all transactions and the database modifications made by each transaction. The transaction log is a critical component of the database and, if there is a system failure, the transaction log might be required to bring your database back to a consistent state. This guide provides information about the physical and logical architecture of the transaction log. Understanding the architecture can improve your effectiveness in managing transaction logs.
VLF stands for Virtual Log File and the transaction log file is made up of one or more virtual log files. The number of virtual log files can grow based on the autogrowth settings for the log file and how often the active transactions are written to disk.
Request: Do read the Article Some downloadable query collection will be provided to you at the last :
DEBATE:
There is always been the debate since the SQL server evolved on the face of earth about the optimized number of VLF files. But then its totally dependent on the database you host the nature of transaction it serves.
But yes many of the most reputed Intellects have tried to solve this mystery and tried to find out the science behind it few are mentoned below do check out for more details.(I personally recommend these for your better understanding of concept)
1: Transaction Log VLFs – too many or too few? -: by Kimberly L. Tripp
2: Important change to VLF creation algorithm in SQL Server 2014 -: Paul S. Randal
3: Bug: log file growth broken for multiples of 4GB -: Paul S. Randal
4: Guide To manage VLFs -: David Levy
So basic formula for the number of VLF files will be created next time the database log file is at the edge of next growth. Follow below stats:
· Up to 64 MB: 4 new VLFs, each roughly 1/4 the size of the growth
· 64 MB to 1 GB: 8 new VLFs, each roughly 1/8 the size of the growth
· More than 1 GB: 16 new VLFs, each roughly 1/16 the size of the growth
The transaction log is a wrap-around file. For example, consider a database with one physical log file divided into four VLFs. When the database is created, the logical log file begins at the start of the physical log file. New log records are added at the end of the logical log and expand toward the end of the physical log. Log truncation frees any virtual logs whose records all appear in front of the minimum recovery log sequence number (MinLSN). The MinLSN is the log sequence number of the oldest log record that is required for a successful database-wide rollback. The transaction log in the example database would look similar to the one in the following illustration.

When the end of the logical log reaches the end of the physical log file, the new log records wrap around to the start of the physical log file.

This cycle repeats endlessly, as long as the end of the logical log never reaches the beginning of the logical log. If the old log records are truncated frequently enough to always leave sufficient room for all the new log records created through the next checkpoint, the log never fills. However, if the end of the logical log does reach the start of the logical log, one of two things occurs:
· If the FILEGROWTH setting is enabled for the log and space is available on the disk, the file is extended by the amount specified in the growth_increment parameter and the new log records are added to the extension. For more information about the FILEGROWTH setting, see ALTER DATABASE File and Filegroup Options (Transact-SQL).
· If the FILEGROWTH setting is not enabled, or the disk that is holding the log file has less free space than the amount specified in growth_increment, an 9002 error is generated. Refer to Troubleshoot a Full Transaction Log for more information.
If the log contains multiple physical log files, the logical log will move through all the physical log files before it wraps back to the start of the first physical log file.
Caution: Virtual log file (VLF) creation follows this method:
· If the next growth is less than 1/8 of current log physical size, then create 1 VLF that covers the growth size (Starting with SQL Server 2014 (12.x))
· If the next growth is more than 1/8 of the current log size, then use the pre-2014 method:
o If growth is less than 64MB, create 4 VLFs that cover the growth size (e.g. for 1 MB growth, create four 256KB VLFs)
o If growth is from 64MB up to 1GB, create 8 VLFs that cover the growth size (e.g. for 512MB growth, create eight 64MB VLFs)
o If growth is larger than 1GB, create 16 VLFs that cover the growth size (e.g. for 8 GB growth, create sixteen 512MB VLFs)
Conclusion:
This is a very critical and unending topic sur to multiple dependencies and hence I rest this here …do check the list of useful links provided here since I don’t think I will be ever writing the blog more cleare and precise like big names in industry.
Thanks Regards
Ajeet Singh
DOWNLOAD:
Find Out VLF count
Click Here
To find the DB with High VLF
Click Here
Determing the position of the last VLF in transaction log before shrinking the log file
Click Here
References disclaimer:
All the details I could bring to you, is because of the great personalities in this profession. I have mentioned links to their blogs. Do visit share your feedback and queries.
Please post queries and Doubts and topics you would like me to blog:
Every SQL Server database transaction log records all transactions and the database modifications made by each transaction. The transaction log is a critical component of the database and, if there is a system failure, the transaction log might be required to bring your database back to a consistent state. This guide provides information about the physical and logical architecture of the transaction log. Understanding the architecture can improve your effectiveness in managing transaction logs.
VLF stands for Virtual Log File and the transaction log file is made up of one or more virtual log files. The number of virtual log files can grow based on the autogrowth settings for the log file and how often the active transactions are written to disk.
Request: Do read the Article Some downloadable query collection will be provided to you at the last :
DEBATE:
There is always been the debate since the SQL server evolved on the face of earth about the optimized number of VLF files. But then its totally dependent on the database you host the nature of transaction it serves.
But yes many of the most reputed Intellects have tried to solve this mystery and tried to find out the science behind it few are mentoned below do check out for more details.(I personally recommend these for your better understanding of concept)
1: Transaction Log VLFs – too many or too few? -: by Kimberly L. Tripp
2: Important change to VLF creation algorithm in SQL Server 2014 -: Paul S. Randal
3: Bug: log file growth broken for multiples of 4GB -: Paul S. Randal
4: Guide To manage VLFs -: David Levy
So basic formula for the number of VLF files will be created next time the database log file is at the edge of next growth. Follow below stats:
· Up to 64 MB: 4 new VLFs, each roughly 1/4 the size of the growth
· 64 MB to 1 GB: 8 new VLFs, each roughly 1/8 the size of the growth
· More than 1 GB: 16 new VLFs, each roughly 1/16 the size of the growth
The transaction log is a wrap-around file. For example, consider a database with one physical log file divided into four VLFs. When the database is created, the logical log file begins at the start of the physical log file. New log records are added at the end of the logical log and expand toward the end of the physical log. Log truncation frees any virtual logs whose records all appear in front of the minimum recovery log sequence number (MinLSN). The MinLSN is the log sequence number of the oldest log record that is required for a successful database-wide rollback. The transaction log in the example database would look similar to the one in the following illustration.
When the end of the logical log reaches the end of the physical log file, the new log records wrap around to the start of the physical log file.
This cycle repeats endlessly, as long as the end of the logical log never reaches the beginning of the logical log. If the old log records are truncated frequently enough to always leave sufficient room for all the new log records created through the next checkpoint, the log never fills. However, if the end of the logical log does reach the start of the logical log, one of two things occurs:
· If the FILEGROWTH setting is enabled for the log and space is available on the disk, the file is extended by the amount specified in the growth_increment parameter and the new log records are added to the extension. For more information about the FILEGROWTH setting, see ALTER DATABASE File and Filegroup Options (Transact-SQL).
· If the FILEGROWTH setting is not enabled, or the disk that is holding the log file has less free space than the amount specified in growth_increment, an 9002 error is generated. Refer to Troubleshoot a Full Transaction Log for more information.
If the log contains multiple physical log files, the logical log will move through all the physical log files before it wraps back to the start of the first physical log file.
Caution: Virtual log file (VLF) creation follows this method:
· If the next growth is less than 1/8 of current log physical size, then create 1 VLF that covers the growth size (Starting with SQL Server 2014 (12.x))
· If the next growth is more than 1/8 of the current log size, then use the pre-2014 method:
o If growth is less than 64MB, create 4 VLFs that cover the growth size (e.g. for 1 MB growth, create four 256KB VLFs)
o If growth is from 64MB up to 1GB, create 8 VLFs that cover the growth size (e.g. for 512MB growth, create eight 64MB VLFs)
o If growth is larger than 1GB, create 16 VLFs that cover the growth size (e.g. for 8 GB growth, create sixteen 512MB VLFs)
Conclusion:
This is a very critical and unending topic sur to multiple dependencies and hence I rest this here …do check the list of useful links provided here since I don’t think I will be ever writing the blog more cleare and precise like big names in industry.
Thanks Regards
Ajeet Singh
DOWNLOAD:
Find Out VLF count
Click Here
To find the DB with High VLF
Click Here
Determing the position of the last VLF in transaction log before shrinking the log file
Click Here
References disclaimer:
All the details I could bring to you, is because of the great personalities in this profession. I have mentioned links to their blogs. Do visit share your feedback and queries.
Please post queries and Doubts and topics you would like me to blog:









