Home / Companies / Tiger Data / Blog / Post Details
Content Deep Dive

The Real Cost of a Single Insert in Postgres

Blog post from Tiger Data

Post Details
Company
Date Published
Author
NanoHertz Communications
Word Count
1,661
Company Posts That Month
7
Language
English
Hacker News Points
-
Post removed?
No
Summary

PostgreSQL write amplification occurs when a small logical insert produces substantially more physical storage and WAL activity due to MVCC tuple headers, page line pointers, index entries, and durability logging. Using a 40-byte sensor reading in a PostgreSQL 16 table with three indexes, the discussion estimates that each insert can generate four WAL records and roughly 345 bytes of WAL, with full-page images after checkpoints causing additional temporary spikes. It provides a SQL-based measurement approach using `pg_current_wal_lsn()` and `pg_stat_wal`, showing sample amplification of about 8.73–10.74 times with three indexes and 2.44 times after removing them, suggesting index maintenance accounts for much of the logging overhead. Recommended reductions include batching writes with COPY or multi-row inserts, removing rarely used indexes, enabling WAL compression, and adjusting checkpoint settings, while noting tradeoffs such as CPU use, recovery time, and WAL disk consumption.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.