Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Presentation HIGHLIGHT
The Anatomy of a Data Modification
Kimberly L. Tripp
President/Founder
The Anatomy of a Data Modification
1. User sends UPDATE
Update is highly selective (only 5 rows)
Indexes exist to aid in finding these rows
efficiently
The update is a SINGLE statement batch NOT
enclosed in BEGIN TRANCOMMIT TRAN block
therefore this is IMPLICIT transaction
2. Server receives the request and locates the
data in cache OR reads the data from disk
into cache
Since this is highly selective only the necessary
pages are read into cache (maybe a few extra but
thats not important here)
Lets use an example where the 5 rows being
modified are located on 3 data pages
Enterprise Database Administration and Deployment SIG
Pre-conference Workshop Tuesday, September 28 8:30 am 4:30 pm
What it Looks Like Data
Data
Log
UPDATE Server
Cache
Update Lock
Row
Page
Update Lock
Cache Row
Update Lock
Row
Page
x x Exclusive
Update Lock
Lock
Row
Page
x x Exclusive
Update Lock
Lock
Cache x
Row
x Exclusive
Update Lock
Lock
Row
Page
(5 Rows Affected)
Data L
Log
5 Rows Affected Server
Log
~~~~~ Cache
~~~~~ Sequential writes
~~~~~ Change
After the log ~~~~~ Change
entries are made ~~~~~ Change
and the locks are ~~ Change
released
4 L Roll forward
5 Roll back
Time
Enterprise Database Administration and Deployment SIG
Pre-conference Workshop Tuesday, September 28 8:30 am 4:30 pm
Key Points
Data Portion mostly random reads except at
checkpoint
Log Portion mostly sequential writes
Separate physical disks minimizes contention
at the drive level first choice in tuning
Log is critical!
Log is written AHEAD of the data portion
Log is the ONLY place where transactional
consistency is known (i.e. guaranteed)
Once a checkpoint occurs SQL Server doesnt need
the information in the log for committed (a.k.a.
inactive) transactions (the log could even be cleared)
However without the transaction log a database
cannot function (i.e. marked suspect)
Then what?
Enterprise Database Administration and Deployment SIG
Pre-conference Workshop Tuesday, September 28 8:30 am 4:30 pm