intermediateTop 30 Scenario-Based Questions
Your PostgreSQL table has 40% dead tuples causing slow queries. How do you fix it with no downtime?
1) Immediate: VACUUM ANALYZE orders — removes dead tuple pointers, updates statistics, no lock. 2) Verify: SELECT n_dead_tup, n_live_tup FROM pg_stat_user_tables WHERE relname='orders' — should drop. 3) Tune autovacuum: ALTER TABLE orders SET (autovacuum_vacuum_scale_factor=0.01, autovacuum_vacuum_threshold=1000). 4) Find long transactions blocking vacuum: SELECT pid, xact_start, state FROM pg_sta
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
Your PostgreSQL table has 40% dead tuples causing slow queries. How do you fix it with no downtime?