PAGE_VERIFY

PAGE_VERIFY is a database option that sets how SQL Server finds out whether a data page was corrupted on disk (torn write, bit error). Unlike PostgreSQL full page writes or the InnoDB doublewrite buffer, SQL Server keeps no separate page copy during normal operation. It only detects corruption; repair means restoring the page from a backup or fetching it from another replica in an availability group.

Key Specifications

ItemValue
ValuesCHECKSUM (default for new databases since 2005), TORN_PAGE_DETECTION (older method), NONE
CHECKSUMRecords a check value for the whole page in the header when the page is written to disk, and compares it on read
TORN_PAGE_DETECTIONRecords 2 bits per 512-byte sector, so it detects only the case where some sectors were written
When corruption is foundError 824 (logical consistency error), recorded in msdb.dbo.suspect_pages
When it takes effectFrom the next page rewrite after the option is changed. Existing pages keep the old method until they are rewritten
Page copyNone normally
Recovery methodPage-level restore (RESTORE DATABASE ... PAGE), automatic page repair in availability groups and mirroring

How It Works

Figure. Detecting and repairing corruption with CHECKSUM

flowchart LR
  A["Write the page to disk<br/>store the check value in the header"] --> B["Read the page later"]
  B --> C{"Is the recomputed check value the same?"}
  C -- "Yes" --> D["Use normally"]
  C -- "No" --> E["Error 824<br/>recorded in suspect_pages"]
  E --> F["Availability group: automatic page repair from another replica"]
  E --> G["Standalone server: restore the page from a backup + apply log backups"]

Diagram description: When a page is written, the check value goes into the header, and on read SQL Server recomputes it and compares. If it differs, the query fails with Error 824 and the page number is left in suspect_pages. In an availability group (or database mirroring), SQL Server fetches a good page from another replica and replaces it automatically. On a standalone server, you restore only that page from a full backup and then apply log backups to bring it up to date. For this reason, a page restore needs the FULL recovery model and an unbroken chain of log backups.

When the check happens. The check runs only when a page is read from disk. A page that stays in the buffer pool, or a page that is never read, is not checked, so run DBCC CHECKDB periodically to make it read every page. BACKUP ... WITH CHECKSUM also verifies the check values while backing up.

Do not use NONE. A corrupt page can be read as is and return wrong results. A database upgraded from an earlier version can remain on TORN_PAGE_DETECTION or NONE, so check it.

Configuration and Inspection

SELECT name, page_verify_option_desc FROM sys.databases;
ALTER DATABASE tune SET PAGE_VERIFY CHECKSUM;

-- Pages where corruption was detected
SELECT database_id, file_id, page_id, event_type, error_count, last_update_date
FROM msdb.dbo.suspect_pages;

-- Check every page
DBCC CHECKDB (N'tune') WITH NO_INFOMSGS, ALL_ERRORMSGS;

-- Restore a single page (FULL recovery model, then apply the log backups in order)
RESTORE DATABASE tune PAGE = '1:57' FROM DISK = N'/var/opt/mssql/backup/tune.bak' WITH NORECOVERY;

Comparison with Other DBMSs

SQL ServerPostgreSQLInnoDBOracle
Tear detectionPAGE_VERIFY CHECKSUMData checksum (initdb option)Page checksumBlock checksum
Intact copyNone normallyFull page image in the WALdoublewrite areaNone normally
RecoveryRestore the page from a backup, automatic repair from a replicaOverwrite with the image, then RedoReplace with the copy, then RedoRMAN block-level recovery

In the Articles

NOTE Defaults and the conditions for automatic page repair can vary by version and configuration.

Related pages