နားလည်ထားရမယ့် အချက်
MVCC ကြောင့် UPDATE/DELETE အဟောင်း row versions ကိုချက်ချင်းမဖယ်ပါဘူး။ Standard VACUUM က space ကို reuse နိုင်အောင်လုပ်ပြီး ANALYZE က planner statistics ပြန်တွက်ပါတယ်။ `VACUUM FULL` က table rewrite နှင့် exclusive lock လိုလို့ routine fix မဟုတ်ပါ။ Long transaction များက cleanup ကိုတားနိုင်ပါတယ်။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
High-update `lesson_progress` table ရဲ့ live/dead tuple estimates နဲ့ last autovacuum/analyze times ကိုကြည့်မယ်။ Bulk load ပြီး ANALYZE လုပ်ပြီး autovacuum threshold ကို per-table ပြင်မယ်ဆိုရင် measurement အရလုပ်ပါ။
အတူတူ စမ်းရေးကြည့်မယ်
SELECT relname, n_live_tup, n_dead_tup,
last_autovacuum, last_autoanalyze
FROM pg_stat_user_tables
WHERE schemaname = 'app'
ORDER BY n_dead_tup DESC;
VACUUM (ANALYZE, VERBOSE) app.lesson_progress;Table maintenance state ကိုမြင်ပြီး targeted VACUUM/ANALYZE run နိုင်မည်။၅ မိနစ် စမ်းကြည့်
Test table ကို update/delete အများကြီးလုပ်ပြီး statistics ကိုကြည့်ကာ VACUUM ANALYZE မတိုင်မီ/ပြီးနောက်နှိုင်းပါ။
သတိလေးတစ်ချက်
Autovacuum ကိုပိတ်ခြင်းက bloat သာမက transaction ID wraparound အန္တရာယ်ထိဖြစ်စေပါတယ်။
PostgreSQL — Routine Vacuuming — PostgreSQL Global Development Group