Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

Does PostgreSQL write first to WAL and then to data files?

$
0
0

This is regarding the synchronous_commit in Postgres.

The synchronous_commit documentation says:

Specifies whether transaction commit will wait for WAL records to be
written to disk before the command returns a “success” indication to
the client

So my understanding is that a transaction will be written to the database first and then WAL files. synchronous_commit determines whether this WAL write is done synchronously or asynchronously.

My problem is, from following documentation:

Briefly, WAL’s central concept is that changes to data files (where tables and indexes reside) must be written only after those changes have been logged, that is, after log records describing the changes have been flushed to permanent storage.

I got the understanding that Postgres first writes transactions to WAL files and then to the datafile (database).

Which one is the correct? Does Postgres write first to WAL and then to data files? Can any one give more details about how synchronous commits happen and how this relates to WAL?


Viewing all articles
Browse latest Browse all 1138

Trending Articles