# 6.2.2 The Pocket Diary (WAL I/O) ![The Pocket Diary](assets/arch_pocket_diary.png) While most chefs complain about waiting for ingredients from the basement, others find themselves standing perfectly still *after* the dish is cooked. Why? Because Postgres is incredibly paranoid. ## The Bolt of Safety (WALWrite) Before any Chef is permitted to tell the Waiter, "Your food is ready!", they must guarantee the dish will survive a sudden power outage. As detailed in **[[Chapter 4/4.1 - The Pocket Diary (WAL & fsync)|Chapter 4]]**, the Chef achieves this by writing a tiny note in the **Write-Ahead Log (WAL)**. This note is the Pocket Diary. It is essential. But writing it down takes time, and ensuring it is physically bolted to the hard drive platters (`fsync`) takes even longer. - **`IO:WALWrite`**: The Chef has finished the transaction and is standing by the ledger, tapping their pen, waiting for the hard drive to confirm the note is permanently recorded. - **`IO:WALSync`**: The physical confirmation process where the OS is forced to flush its caches down to raw metal. If your kitchen is overwhelmed by these `WAL` waits, it usually means your chefs are trying to write thousands of distinct, tiny notes per second. To speed it up, you can either buy a much faster pen (an NVMe disk dedicated entirely to the `pg_wal` directory), or you can ask the chefs to batch their notes together before walking over to the ledger—by tuning `commit_delay` or using asynchronous commits (if you are willing to risk losing half a second of recent orders). > [!info] Diagnostics: WAL Write Latency > To see the full taxonomy of ledger stalls—including initialization and synchronization waits—browse the **[[Workloads/IO/WAL/_WAL|WAL I/O Event Library]]**. --- | ← Previous | ↑ Table of Contents | Next → | | :--- | :---: | ---: | | [[Chapter 6/6.2.1 - The Frozen Pantry (DataFile & BufFile IO)\|6.2.1 The Frozen Pantry (DataFile & BufFile IO)]] | [[Learn You a Postgres for Great Good\|Home]] | [[Chapter 6/6.2.3 - The Master Key (ControlFile & RelationMap)\|6.2.3 The Master Key (ControlFile & RelationMap)]] |