๐Ÿš€ Introduction

Have you ever wondered how PostgreSQL can handle hundreds of concurrent updates and still feel blazing fast?

If Postgres tried to update every piece of data directly on disk at commit time, performance would slow down dramatically. Why? Because accessing and writing to random pages in memory and on disk is costly.

Instead, Postgres uses a smarter approach.

If youโ€™re curious about the deep internals of how Postgres manages this trick โ€” and want to walk away with a clear mental model of what happens when you run an UPDATE โ€” keep reading. By the end of this article, youโ€™ll be proficient in one of the most important mechanisms inside Postgres.


โŒ›ย TL;DR


๐Ÿ“ What is WAL?

<aside> ๐Ÿ’ก

WAL (Write-Ahead Logging) is a fundamental technique in databases where all changes are first written to a sequential log before being applied to the actual data files.

</aside>

โ›”ย Without WAL:

โœ…ย With WAL: