PostgreSQL UNLOGGED Table Emptied After Crash/Restart

UNLOGGED tables skip WAL by design and are automatically truncated on unclean recovery.

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.1.0
Identifier: PostgreSQL UNLOGGED Table Emptied After Crash/Restart Platform: PostgreSQL
Common Root Causes:
  • UNLOGGED tables skip WAL by design and are automatically truncated on unclean recovery.

Interactive Diagnostic Checklist

Verified Solutions:
  1. Use UNLOGGED only for disposable caches; convert durable tables with `ALTER TABLE ... SET LOGGED`.
Safe Diagnostic Command:
SELECT relname, relpersistence FROM pg_class WHERE relpersistence = 'u';
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.

Technical Explanation

UNLOGGED tables skip WAL by design and are automatically truncated on unclean recovery. Recommended diagnostic: `SELECT relname, relpersistence FROM pg_class WHERE relpersistence = 'u';`. Remediation: Use UNLOGGED only for disposable caches; convert durable tables with `ALTER TABLE ... SET LOGGED`.

Worked Examples

  • Run `SELECT relname, relpersistence FROM pg_class WHERE relpersistence = 'u';` to verify root cause before applying the remediation.

Limitations & Assumptions

  • Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.

Source References & Verification

Resource ID: err-pg-unlogged-table-truncated-crash · Independently verified: 2026-11-25

Related Resources