TLDR Tech / Data
When upserts don't update but still write: Debugging Postgres performance at scale
Datadog hit a surprising Postgres performance issue while cleaning up millions of ephemeral hosts: a simple upsert to update the 'last seen' timestamp doubled disk writes and quadrupled WAL syncs. The cause was ON CONFLICT DO UPDATE always acquires a row lock and writes to the WAL, even when no data actually changes. The fix is to avoid locking on no-op upserts.
Read the full story