Log File Growth

  • We are using sql server 2008r2

    We have transactional log backup set up for every 15 min.

    We are running default reorg indexes for all tables in one of our production databases daily night.

    Currently our log file size is greater than the data file size.

    Why the transactional log backup is not reducing the log file size?

    If we shrink the log everyday, is there any negative effects?

  • ramana3327 (5/18/2015)


    We are using sql server 2008r2

    We have transactional log backup set up for every 15 min.

    We are running default reorg indexes for all tables in one of our production databases daily night.

    Currently our log file size is greater than the data file size.

    Why the transactional log backup is not reducing the log file size?

    If we shrink the log everyday, is there any negative effects?

    Transaction log backups does not shrink the physical size of the transaction log. It marks the VLF that are reusable. If you are rebuilding/reorganizing every index in the database, this is causing the growth of the t-log. If you are shrinking every day, it has to regrow every noght when you run your reorganization.

  • So i.e. in my case the backups are not marking the VLF to reuse.

    What could be the reason? Is this could be a bug?

    Is rebuild Indexes also requires the same space?

  • ramana3327 (5/18/2015)


    So i.e. in my case the backups are not marking the VLF to reuse.

    What could be the reason? Is this could be a bug?

    Is rebuild Indexes also requires the same space?

    No, the t-log backups are most likely marking your VLFs for reuse. Your reorg/rebuild of every index in the database every night is probably causing the excessive growth of your t-log that you shrink every day. If the VLFs were not marked for reuse, you wouldn't be able to shrink your t-log file.

  • Hi Lynn,

    Thanks for your reply.

    I am not clear about some questions

    1) Does Reorganizing 5 indexes on a table and rebuilding the 5 indexes on the same table requires same log?

    2) I shrink the log file only 2 times. If I want to shrink the log file everyday after the maintenance job it will impact any performance?

    I read in some blog shrinking the logfile will increase VLFs and more fragmentation

    3) Rebuilding the indexes is faster or not than reorg?

  • select * from sys.databases

    run this query

    it will tell you why the log files are not getting reuse

    it will have reason in column log_reuse_wait

  • ramana3327 (5/18/2015)


    2) I shrink the log file only 2 times. If I want to shrink the log file everyday after the maintenance job it will impact any performance?

    Yes. Do not shrink your log regularly, it's very bad practice.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (5/19/2015)


    ramana3327 (5/18/2015)


    2) I shrink the log file only 2 times. If I want to shrink the log file everyday after the maintenance job it will impact any performance?

    Yes. Do not shrink your log regularly, it's very bad practice.

    Gail Is there something called Non-destructive shrinking ??

    i dont know but heard some one was saying that this thing exesist

  • Almighty (5/19/2015)


    Gail Is there something called Non-destructive shrinking ??

    Well shrinking's never destructive.... I said it's bad practice, not that it's going to destroy something.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Is it possible to use temp db for reorg index job like rebuild index instead of log?

  • No, and rebuild doesn't use TempDB instead of the log either. Rebuild uses TempDB for sort space, space that would otherwise come from the user database's data file. Reorganise doesn't sort, so it doesn't need sort space at all.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • You should only rebuild or reorganize an index when it is fragmented enough to be significant. For some tables, this might be every day. For others, only every week or even every month. It's a huge waste of resources to rebuild/reorg every index every night. And you would never do both rebuild and reorg on the same index, just one of the two, as appropriate.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • My Understanding is below

    so either rebuild index or reorg index will use the transactional log and increase the physical log usage.

    so if the log file initial size is 50MB and we started reorg indexes job, then it grows 160GB. So we can't get that initial physical log size (50 MB) even after the reorg job completes, until we shrink the log file manually after the backup

    The regular transactional log backups will reduce only logical log size but to reduce the physical log only one option is we have to shrink log file

  • ramana3327 (5/19/2015)


    so either rebuild index or reorg index will use the transactional log and increase the physical log usage. We can't get that initial physical log size until we shrink

    The regular transactional log backups will reduce only logical log size but to reduce the physical log only one option is we have to shrink log file

    Is there a reason you need to shrink the physical log file?

  • ramana3327 (5/19/2015)


    so if the log file initial size is 50MB and we started reorg indexes job, then it grows 160GB. So we can't get that initial physical log size (50 MB) even after the reorg job completes, until we shrink the log file manually after the backup

    The regular transactional log backups will reduce only logical log size but to reduce the physical log only one option is we have to shrink log file

    Why shrink it? What are you gaining other than extra work? If it need to be 160GB every night, then why waste time and effort shrinking it to 50GB just so that it can grow back to 160GB every night.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 15 posts - 1 through 15 (of 22 total)

You must be logged in to reply to this topic. Login to reply