Spring 2011
Transactions
Information Management
Information Management
Agenda
SQL Concurrency and Isolation
Special Columns
Insert, Delete, Update Operations
Aborting a transaction
Invisibility List
Information Management
Information Management
Information Management
Special Columns
createxid
deletexid
rowid
Null Vector
row length
8 bytes
8 bytes
8 bytes
N/8 Bytes
4 Bytes
Column_1..Column_n
Number of bytes..
In all tables, every record includes three 8-byte special columns, representing:
rowid
unique row ID
createXid
the transaction ID of the transaction that created the row
deleteXid
the transaction ID of the transaction that deleted the row
These columns can be seen using SELECT rowid, createXid, deleteXid
Information Management
rowid
createxid
deletexid
rowid
Null Vector
row length
8 bytes
8 bytes
8 bytes
N/8 Bytes
4 Bytes
Column_1..Column_n
Number of bytes..
Information Management
deletexid
rowid
Null Vector
row length
8 bytes
8 bytes
8 bytes
N/8 Bytes
4 Bytes
Column_1..Column_n
Number of bytes..
Information Management
deletexid
rowid
1024
100000
row
To delete a row, createxid is untouched, with deletexid marked with the transaction id
deletexid
rowid
1024
1025
100000
row
Information Management
Updating a Row
Rows are NOT updated in-place on disk
The original record is marked for deletion (logically deleted) and the deleteXid
value is updated
A new record, with the same rowid, is INSERTed and the createXid and
deleteXid values are updated
Maintains data integrity
Write once
No transactional log files
Simplifies and accelerates rollback/recovery operations
Information Management
Example of an Update
Transaction 1027: UPDATE SET changed_data WHERE data =
ORIGINAL
createxid
deletexid
rowid
1024
100000
row
Row is updated
The original record is marked as deleted
createxid
deletexid
rowid
row
1024
1027
100000
1027
100000
Information Management
deletexid
rowid
2100
100000
row
Aborting an DELETE:
createxid
deletexid
rowid
2300
300000
row
DELETE is aborted
The deletexid is simply set back to a value of 0
11
Information Management
createxid
deletexid
rowid
2200
200000
2201
200000
UPDATE is aborted
System reverts to the prior version of the record
12
Information Management
Invisibility lists
When a query or backup operation is executed, it is allowed to access rows that
were created but not deleted before the transaction began
xid values are sequential, it simply needs to compare the createXid and deleteXid
values
An invisible list is created, consists of lower xid value that it needs to ignore, ie
any other active transactions or transaction or transactions that have not finished
rolling back
Any records created (but not committed) are excluded
Any records deleted (but not committed) are included
13
Questions?
Information Management