How to reduce the VLFs

Sam 1,476 Reputation points
2024-03-19T13:14:52.2266667+00:00

Hi All,

We have a database with 5TB size and has VLF near to 900.

Transaction log file size 700GB.

We are on SQL Server 2017 EE Always on availability group.

During restores/db refreshes and during AG fail over times it is taking 30-45 mins to bring the database online.

Question is how to reduce the VLFs? I don't want to remove the database from AG and if we have to resize the log file with MINIMAL DOWN TIME, then what are the precautions needs to be taken?

Regards,

Sam

SQL Server Other
{count} votes

1 answer

Sort by: Most helpful
  1. LiHongMSFT-4306 31,566 Reputation points
    2024-03-20T03:33:53.7433333+00:00

    Hi @Samantha r

    First you need to determine if you have a high VLF count.

    Then fix a database with a high VLF count in below process:

    1. Check the current size of the transaction log.
    2. Backup the transaction log.
    3. Shrink the transaction log to as close to 0 KB as possible.
    4. Check that the VLFs are reduced to a lower number.
    5. Grow the transaction log back out to the original size.

    See this blog for more details.

    Best regards,

    Cosmog Hong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.