Shadow Paging in DBMS: Working, Advantages & Examples

Published: 2025-01-28
7 min read
Share:

Shadow paging in DBMS is a database recovery technique that maintains two versions of data pages: the original stable pages and the modified pages created during a transaction. Instead of relying heavily on logs for recovery, the database keeps the original pages untouched until a transaction successfully commits.

This approach makes crash recovery straightforward. If a failure occurs before a transaction commits, the database simply ignores the modified pages and continues using the original ones. Because of this behavior, shadow paging is often discussed alongside concepts such as recovery and atomicity in DBMS.

Why Shadow Paging Is Important in DBMS

Ensuring Data Integrity

Data integrity is one of the primary goals of any database system. Shadow paging guarantees that partially completed transactions never corrupt the database because the original pages remain unchanged until commit.

Even if a system crashes during an update, the database can return to a consistent state immediately.

Simplifying Recovery

Traditional recovery systems often depend on logs, checkpoints, and recovery procedures after a crash.

With shadow paging, recovery is much simpler:

  • No transaction rollback is required for uncommitted changes.
  • No log scanning is needed.
  • Recovery time is significantly reduced.

Predictable Performance

In environments where updates are relatively infrequent, shadow paging can reduce the complexity associated with extensive logging.

For many small and medium-sized databases, this results in a predictable recovery process and easier maintenance.

How Shadow Paging Works in DBMS

Current Pages and Shadow Pages

The mechanism revolves around two page versions:

  • Shadow Pages: Original pages that contain committed data.
  • Current Pages: Newly created pages that contain modifications made during a transaction.

Instead of overwriting existing data, the DBMS creates a new copy whenever a page is modified.

To understand how pages are organized physically within a database system, you can also explore storage structure in DBMS.

Page Table Switching

The database maintains a page table that maps logical pages to physical storage locations.

During a transaction:

  1. Original page mappings remain untouched.
  2. Modified pages are written to new locations.
  3. The page table temporarily references the new pages.
  4. On commit, the page table switches permanently to the updated pages.

This process is known as page table switching.

Practical Example of Shadow Paging

Suppose page P5 stores customer account information.

A transaction updates the account balance:

  1. The DBMS creates a new copy of page P5.
  2. Updates are written to the new page.
  3. The original page remains unchanged.
  4. If the transaction commits successfully, the page table points to the new page.
  5. If the transaction fails, the database simply continues using the original page.

This approach ensures that incomplete updates never affect committed data.

Shadow Paging vs Log-Based Recovery

Shadow paging and logging solve the same recovery problem but use different approaches.

If you want a deeper understanding of logging-based approaches, see log-based recovery in DBMS.

Shadow Paging

  • Maintains original and modified page copies.
  • Does not require redo operations.
  • Does not require undo operations.
  • Recovery is typically very fast.
  • Requires additional storage space.

Log-Based Recovery

  • Stores transaction records in logs.
  • Uses redo and undo operations during recovery.
  • Supports more advanced recovery scenarios.
  • Usually consumes less storage than shadow paging.
  • Can handle highly transactional workloads more efficiently.

When to Choose Each Approach

Shadow paging is often a better fit when:

  • Fast recovery is a priority.
  • Database updates are relatively infrequent.
  • Simplicity is preferred over advanced recovery capabilities.

Log-based recovery is generally preferred when:

  • Transactions occur frequently.
  • Fine-grained rollback is required.
  • The database handles large-scale workloads.

Step-by-Step Shadow Paging Process

The following sequence illustrates how the mechanism works.

Step 1: Initial State

The page table points to stable shadow pages that contain committed data.

Step 2: Transaction Begins

Whenever a page is modified:

  • The original page remains untouched.
  • A new page is created.
  • Updates are written to the new page.

Step 3: Commit Operation

When the transaction commits:

  • The page table switches to the new pages.
  • The updated pages become the official database state.
  • Old shadow pages can eventually be removed.

Step 4: Abort or Crash

If a failure occurs before commit:

  • Modified pages are discarded.
  • Original shadow pages remain valid.
  • The database immediately returns to a consistent state.

Because of this process, transactions never leave partially written data behind.

How Shadow Paging Handles Database Failures

Transaction Failures

A transaction may fail because of:

  • Invalid input
  • Application errors
  • Constraint violations

Since original pages are never overwritten, recovery simply means discarding the modified copies.

System Failures

Power outages, operating system crashes, or unexpected shutdowns can interrupt transactions.

When the database restarts, it continues using the shadow pages and restores consistency without replaying logs.

Media Failures

Shadow paging is not a substitute for backups.

If a storage device fails completely, the database still requires:

  • Backups
  • Replication
  • Disaster recovery strategies

Shadow paging mainly protects against transaction and system failures.

Performance Trade-Offs of Shadow Paging

Before implementing shadow paging, it is important to understand the associated costs.

Storage Overhead

The system maintains both original and modified page versions.

As a result:

  • Additional disk space is required.
  • Storage consumption increases as updates grow.

Write Overhead

Every modification requires page copying.

This means:

  • More write operations occur.
  • Update-heavy workloads may experience performance penalties.

Recovery Benefits

The recovery process is extremely fast because:

  • No redo processing is required.
  • No undo processing is required.
  • No log scanning is required.

Pro Tip

Shadow paging performs best in read-heavy environments where updates occur less frequently. In write-intensive systems, constant page copying can become a bottleneck.

Can Shadow Paging Be Combined With Other Recovery Methods?

Modern database systems often combine multiple recovery strategies.

Combining Shadow Paging and Logging

Some systems use shadow paging for fast crash recovery while retaining limited logging for:

  • Auditing
  • Incremental backups
  • Distributed transactions

This hybrid approach offers greater flexibility.

Integration with Modern Database Technologies

Shadow paging can also work alongside technologies such as:

  • Multi-Version Concurrency Control (MVCC)
  • Replication systems
  • Distributed database architectures

Combining these techniques can improve availability and fault tolerance.

Where Shadow Paging Works Best

Small and Medium Databases

Smaller systems often benefit from the simplicity of shadow paging because recovery is easy to manage.

Read-Heavy Applications

Applications that perform many reads and relatively few updates can take advantage of fast recovery without excessive page-copying overhead.

Systems Requiring Fast Recovery

Organizations that prioritize quick recovery times often find shadow paging attractive because recovery can occur almost instantly after a crash.

Limitations of Shadow Paging

Despite its advantages, shadow paging is not suitable for every environment.

Increased Storage Usage

Maintaining multiple page versions requires more storage capacity.

Limited Recovery Flexibility

Unlike logging systems, shadow paging does not provide detailed transaction replay or granular rollback capabilities.

Less Suitable for Write-Heavy Workloads

Frequent updates create significant page-copying overhead, which can affect overall system performance.

Frequently Asked Questions

What is shadow paging in DBMS?

Shadow paging is a recovery technique that keeps original pages unchanged while writing updates to new pages. If a transaction fails, the database simply continues using the original pages.

What is page table switching?

Page table switching is the process of updating page mappings so that the database starts referencing newly modified pages after a successful transaction commit.

How is shadow paging different from logging?

Logging relies on redo and undo operations during recovery, whereas shadow paging recovers by reverting to the original pages without replaying transaction logs.

Does shadow paging require additional storage?

Yes. Since both original and modified page versions exist simultaneously, storage requirements are higher than many logging-based approaches.

Is shadow paging used in modern databases?

While many modern databases rely primarily on write-ahead logging (WAL), shadow paging concepts still appear in certain database architectures, storage engines, and academic implementations because of their simplicity and fast recovery characteristics.

Free Engineering ToolsNEW

8 free, 100% client-side tools for developers — no signup, no data uploads.

Explore all tools