liveBook · Manning

Pageinspect

As explained in PostgreSQL Mistakes and How to Avoid Them

pageinspect is a PostgreSQL extension that provides functions for inspecting the contents and metadata of database pages.

pageinspect is a PostgreSQL extension for validating whether pages in a restored database are readable and internally consistent. It turns backup testing from a startup-only check into a page-by-page inspection. section 9.4

Use pageinspect during a restored-backup fire drill to inspect every page of every relation:

  • Read each page from disk with get_raw_page(). section 9.4
  • Inspect the page header with page_header(). section 9.4
  • Verify the page checksum with page_checksum(). section 9.4

Restored-backup validation

After copying a base backup and subsequent WAL into a test PGDATA directory, start PostgreSQL to reach a consistent state, then use pageinspect to check every page for readability, valid headers, and valid checksums. Automate the procedure and alert on errors. section 9.4

How PostgreSQL Mistakes and How to Avoid Them covers it

How deep it goes
Explains a page-by-page procedure using three functions, but defers detailed SQL and extension reference material.
Examples
Uses a restored PGDATA directory and every page of every relation as the concrete validation target.
What it assumes
Assumes PostgreSQL backup restoration, WAL handling, and database consistency; teaches the page-level verification step.
What you can do after
Diagnose restored-backup corruption by reading pages, checking headers, verifying checksums, and automating error alerts.
How it connects
Connects page inspection with base backups, WAL, checksums, PostgreSQL recovery, and backup verification.

This explainer was generated by Manning's knowledge graph from the text of PostgreSQL Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.