Durability Trade-Offs

Learn about the durability of transactions in PostgreSQL.

Durability is the D of the ACID guarantees, and it refers to the property that our database management system is not allowed to miss any committed transaction after a restart or a crash—any crash. It’s a very strong guarantee, and it can impact performance behavior a lot.

Of course, by default, PostgreSQL applies a strong durability guarantee to every transaction. As we can see in the documentation about asynchronous commit, it’s possible to relax that guarantee for enhanced write capacity.

PostgreSQL allows synchronous_commit to be set differently for each concurrent transaction of the system and to be changed in flight within a transaction. After all, this setting controls the behavior of the server at transaction commit time.

Reducing the write

Reducing the write guarantees is helpful for sustaining some really heavy write workloads, and that’s easy to do with PostgreSQL. One way to implement different durability policies in the same application would be to assign a different level of guarantee to different users, which we can do in the following way:

Get hands-on with 1400+ tech skills courses.