intermediatePostgreSQL Specifics — MVCC, JSONB & VACUUM
A high-traffic table is showing 40% bloat (dead tuples). Queries are getting slower. How do you fix it without downtime?
1) Verify bloat: SELECT relname, n_dead_tup, n_live_tup, ROUND(n_dead_tup * 100.0 / (n_live_tup + n_dead_tup), 2) AS dead_pct FROM pg_stat_user_tables WHERE relname = 'orders'. 2) Check if autovacuum is running: SELECT last_autovacuum, autovacuum_count FROM pg_stat_user_tables WHERE relname = 'orders'. If never/rarely: autovacuum is overwhelmed. 3) Immediate fix: VACUUM ANALYZE orders — removes de
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
A high-traffic table is showing 40% bloat (dead tuples). Queries are getting slower. How do you fix it without downtime?