intermediateTransactions — ACID, COMMIT, ROLLBACK, SAVEPOINT

How does PostgreSQL ensure durability with WAL?

WAL (Write-Ahead Log): before any data page is modified, a log record is written to WAL. On COMMIT: PostgreSQL flushes WAL records for the transaction to disk (fsync). Returns success to client only after WAL is durable. On crash: PostgreSQL replays WAL from last checkpoint to recover all committed transactions. Changes not in WAL are lost (should only be uncommitted). fsync=on (default): ensures

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to A bank transfer application deducts money from Account A but the credit to Account B fails. How do transactions prevent data corruption?← Back to all SQL questions