• GilaMonster (8/24/2013)


    Jeff Moden (8/24/2013)


    the data isn't actually written as you would think until the transaction is committed.

    In both cases the data changes are made to pages in memory and those changes will be written to disk later. Later is not at the point the transaction is committed, it's any time before or after that. There's no difference here between individual statements and an explicit transaction.

    When that happens, it's done as a single transaction from the Log file to the table.

    Nothing moves from the log file to the table when a transaction commits.

    What happens when a transaction commits is that the log records describing that change are written to disk. For individual statements, that's one log write after each one. For a single explicit transaction, that's a log write at the commit with maybe a couple more during the operation, depending on the size of the log records and other factors.

    The explicit transaction will have much fewer log writes, so much less time in writing to the log file on disk (viewable as writelog waits). That's why it's faster.

    And that, ladies and gentlemen, is the "someone" I was talking about. Thanks, Gail.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)