Search This Blog

Tuesday, September 4, 2007

What happens internally when a UPDATE statement is issued

First,user issues a update statement inside a transaction.

If the record to be modified is not in the buffer cache thenSQL Server reads the same from data page and places it memory within the buffer cache.

The user modifies the record within the buffer cache. Modified pages within the buffer cache are marked as being ‘dirty’ and they will have to be written to disk in the future.

Immediately after the record is modified within the buffer cache, a corresponding record indicating the data change and the transaction that caused the data change is written to the
log cache.

When a commit happends the log cache information is written to the transaction log file on disk.

And when a checkpoint occurs, data is written to data file (.mdf,.ndf) on physical disk.

So,dirty pages within the buffer cache are “flushed” to disk and also data from the log file is
re-applied to data file to make the changes available in the full backup.

No comments: