written 5.4 years ago by |
Shadow paging:-
1.It consider the database to be made up of a number of fixed size disk pages.
2.A directory with 'n' entries is constructed, where the ith database page on disk.
3.The directory is kept in main memory if it is not too large & all read & write references, to the database pages on disk go through it.
4.When a transaction begin executing, the current directory, whose entries point to the most recent or current database pages on disk, is copied into a shallow directory the shadow directory is then saved on disk while the current directory is used by the transaction.
5.During transaction execution, the shadow directory is never modified. When a write_item operation is performed, a new copy of the modified database page is created, but the copy of that page is not overwrite.
6.Instead, the new page is written elsewhere, on same previously unused disk block. The current directory entry is modified to point to the new disk block, whereas the shadow directory is not modified & continues to the point to the old unmodified block.
Log Based Recovery:-
1.It is one of the most widely used structure for database modifications recording is the log.
2.Log can be defined as a sequence of log records recording all the update activities in the database.
3.Log record contains various fields such as transaction identifier, data item identifier, old value & new value.
4.Whenever a transaction performs a write, it is essential that the log record for that write be created before the database is modified .
5.Once a log record exists, we can output the modification to the database of that is desirable.
6.Also, we have the ability to undo a modification that has already been output to the database.
7.We undo it by using the old-value field in log records.
Comparison:-
1.In terms of overhead cost:- In shadow paging system, the overhead of log-record output is eliminated & the recovery from crashes is significantly faster since no undo or redo operations are needed.
2.In terms of implementation:- All logs are written on to the stable storage by the database is updated when a transaction commits, thus implementation is not easy as compared to shadow paging recovery.