Document ID: 35217.1
Subject: When Snapshot Logs get Purged
Author: TOSCROFT
Modified: 12 Sep 96
How a Fast Refresh is Performed:
-------------------------------
MASTER SNAPSHOT
------ -----------
| EMP |--------------------------------------| EMP_SNAP1 |
------ -----------
| | -----------
| |______________________________________| EMP_SNAP2 |
| | -----------
| | -----------
| |______________________________________| EMP_SNAP3 |
| -----------
| SLOG$
-----------------------------
|..|SNAPSHOT.|..| snaptime|...|
-----------------------------
|..|EMP_SNAP1|..| 10-06-95|...|
-----------------------------
|..|EMP_SNAP2|..| 11-06-95|...|
-----------------------------
|..|EMP_SNAP3|..| 12-06-95|...|
-----------------------------
|
|
|
MLOG$_EMP |
----------------------------
| M_ROW | SNAPTIME | DMLTYPE |
----------------------------
| rowid | 10-06-95 | U |
----------------------------
| rowid | 10-06-95 | I |
----------------------------
1. Changes are made to EMP. The altered rowids and the DML_TYPE are stored
in the snapshot log (MLOG$_EMP). No snapshots have refreshed so SNAPTIME
in the snapshot log is set to NULL.
2. EMP_SNAP1 refreshes. As SNAPTIME in MLOG$_EMP is NULL it knows that no
other snapshots have refreshed from these values so it updates SNAPTIME
to its refresh time, eg: 12:00:00 10-06-95. No other snapshots will
update this value until all snapshots have been refreshed and the log
has been purged. It also updates SLOG$ to put its SNAPTIME to 12:00:00
10-06-95.
3. EMP_SNAP2 refreshes and updates SNAPTIME in SLOG$ to its refresh time
(eg: 12:00:00 11-06-95). It then compares the oldest SNAPTIME in SLOG$
for EMP to the time in SNAPTIME in MLOG$_EMP. As the SNAPTIME in SLOG$
is either NULL or before 10-06-95 for EMP_SNAP3, it does not purge the
snapshot log (MLOG$_EMP), nor does it update it.
4. EMP_SNAP3 refreshes and updates SNAPTIME in SLOG$ to its refresh time
(eg: 12:00:00 12-06-95). It compares the oldest SNAPTIME in SLOG$ for
EMP to the SNAPTIME in MLOG$_EMP. As the oldest SNAPTIME in SLOG$ is now
that for EMP_SNAP1, which is the same as that in MLOG$_EMP, it knows
that all snapshots have refreshed therefore purges the rows with a
SNAPTIME equal to or older than the oldest SNAPTIME in SLOG$ for
EMP.
If a snapshot is lost, eg: the machine is taken offline without the
snapshot being dropped first, its SNAPTIME in SLOG$ will not be updated
so the oldest value for SNAPTIME will always be older than the SNAPTIME
in MLOG$_EMP. This means that the entries in MLOG$_EMP will never be
purged during a refresh: they will have to be removed using
dbms_snapshot.purge_log().