How are logs written?

  • Hi everyone,

    If I have two log files in a databases, how does SQL 2000 write to the log files? Does it write to both at the same time if several transactions are running? Thanks.

  • From Books Online "Transaction Log PHysical Architecture"

    "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, which grows toward the end of the physical log"

    "If the log contains multiple physical log files, then the logical log will move through all of the physical log files before it wraps back to the start of the first physical log file."

    In other words, SQL Server works with one physical log file at a time, moving through it sequentially. 

    Scott Thornburg

  • Thank you very much Scott.

    I was wondering the same thing about tempdb. If the tempdb has more than one data file, and there are multiple transactions on the database at a given time, will sql write to each file one by one or to all files at the same time? Thank you again.

  • It does not work that way. Transactions are written to the log file when they occur, and then written to the data file(s) at 'regular' intervals (during checkpoints). There is nothing special about tempdb versus other databases with this.

    Regarding log files: I do not know of any reason to have more than one log file. Like Scott said, only one will be used at a time, and I know of some problems that can occur if you have more than one.

  • I'll join the club here.

    Since you have no control what is written to which log file, having multiple files will yield you nothing.

     

    ...except even more trouble in case of a disaster.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Thanks everyone for ur help on this.

Viewing 6 posts - 1 through 5 (of 5 total)

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