Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


What happens when there is update to rows (in terms of database internals)


What happens when there is update to rows (in terms of database internals)

Author
Message
Mani-584606
Mani-584606
Mr or Mrs. 500
Mr or Mrs. 500 (590 reputation)Mr or Mrs. 500 (590 reputation)Mr or Mrs. 500 (590 reputation)Mr or Mrs. 500 (590 reputation)Mr or Mrs. 500 (590 reputation)Mr or Mrs. 500 (590 reputation)Mr or Mrs. 500 (590 reputation)Mr or Mrs. 500 (590 reputation)

Group: General Forum Members
Points: 590 Visits: 1998
Hi,

What happens when there is update to rows (in terms of database internals)?

Thanks
Dird
Dird
SSC Veteran
SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)

Group: General Forum Members
Points: 212 Visits: 771
My assumption would be that after the syntax of the DML statement was validated the appropriate rows (based on the where clause) are loaded into memory with these rows being marked so that they're locked from others updating them. The appropriate redo & undo change vectors are generated (does somebody know by what process?) related to this update; the redo & undo being written to the TLog by lazywriter and the undo record is logged in the tempdp. Then the operations are applied in memory and, assuming the update wasnt in a still running transaction then the update is commited & others can see it. Row level locks are removed & the tempdb record is marked as being no longer needed (due to the commit).

Or something is wrong here?

Dird


Dird
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47259 Visits: 44392
Close enough.

Dird (4/20/2013)
the redo & undo being written to the TLog by lazywriter


Lazy writer does not do writes to the transaction log.

and the undo record is logged in the tempdp.

Only if the DB is running in one of the row version isolation levels or there's an update trigger (and if there is, it's the previous version, not the undo info)


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


Dird
Dird
SSC Veteran
SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)

Group: General Forum Members
Points: 212 Visits: 771
GilaMonster (4/20/2013)
Lazy writer does not do writes to the transaction log.


Oh lol I meant log writer -_ I should have just said LGWR like i wanted to >_< (http://www.pasteall.org/pic/show.php?id=49671)

and the undo record is logged in the tempdp.

Only if the DB is running in one of the row version isolation levels or there's an update trigger (and if there is, it's the previous version, not the undo info)[/quote]

Ah OK yeah, my answer was very much Oracle focused so I forgot that SQL lets you see uncommited data changes.

Edit: Do you know what process generates the change vectors? :o

Dird


Dird
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47259 Visits: 44392
Dird (4/20/2013)
GilaMonster (4/20/2013)
Lazy writer does not do writes to the transaction log.


Oh lol I meant log writer -_ I should have just said LGWR like i wanted to >_<


It's not the log writer process that logs the changes either. It's the process running the update that generates the log records (and they're just the changed columns) and writes it to the log.

Log writer and lazy writer are only concerned with writing already made log records/changes to disk.


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


Dird
Dird
SSC Veteran
SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)

Group: General Forum Members
Points: 212 Visits: 771
GilaMonster (4/21/2013)
It's not the log writer process that logs the changes either.


Log writer and lazy writer are only concerned with writing already made log records/changes to disk.


Is writing it to disk (the TLog) not logging the changes?

Dird


Dird
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47259 Visits: 44392
Google: log buffer. :-)


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


Dird
Dird
SSC Veteran
SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)

Group: General Forum Members
Points: 212 Visits: 771
That doesn't address the question >_< but yeah it seems it is the log writer is in charge of the logging~ nothing's in a commited state while its still in memory (i.e. log buffer) until lgwr flushes it out to the TLog.

Dird


Dird
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47259 Visits: 44392
Yes it does answer the question.

Process making the changes generates the log records and puts them into the log buffer (logs the changes). Log writer writes the log records to disk before the transaction commits or data pages are written to disk (hardens the log records)


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


Dird
Dird
SSC Veteran
SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)SSC Veteran (212 reputation)

Group: General Forum Members
Points: 212 Visits: 771
Hardens the log w00t


Dird
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search