BitPage

Databases

PostgreSQL, ClickHouse, MySQL. Migrations, optimization under load, incident post-mortems, escaping rules, common traps in mixed stacks.

2 articles

PostgreSQL index bloat: why VACUUM never shrinks an index, and how to measure it with avg_leaf_density

A b-tree that has lost most of its keys keeps every page it allocated: PostgreSQL reclaims completely empty index pages, but a page with a few keys left on it stays put, and no autovacuum setting changes that. Measure the damage with pgstatindex.avg_leaf_density against the b-tree default fillfactor of 90, predict the recovery as size x density / 90, and fix it with REINDEX rather than VACUUM FULL.

PostgreSQL conflict with recovery: why both standard fixes make it worse under Patroni

With replication slots enabled, hot_standby_feedback moves the bloat risk onto the primary; raising max_standby_streaming_delay feeds the HAProxy check that ejects the replica. Two hundred cancelled queries and thirty-odd replica ejections looked like one problem, but barely one in twenty lined up.