PostgreSQL Enterprise (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
What is Write-Ahead Logging (WAL) and Point-In-Time Recovery (PITR)?
senior LevelpostgresqlAdvanced Internals
In Simple Words:
- WAL: All changes are written to 16 MB WAL segment files before data pages are updated in shared buffers. Fsync guarantees durability.
- Continuous Archiving: Completed WAL files are continuously shipped to cloud object storage (S3/GCS).
- PITR (Point-In-Time Recovery): In the event of an accidental
DROP TABLEat14:32:15:- Restore the most recent base backup.
- Replay archived WAL logs up to
recovery_target_time = '2026-03-15 14:32:14'. - Database recovers to the exact second prior to the catastrophic command!