عرض عملي: معاملة خاملة تعطّل vacuum
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
create bloat with an idle transaction and fix it.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Create a hot table
stock_logand a loop that updates rows continuously; show baseline size andn_dead_tup. - In another session run
BEGIN; SELECT count(*) FROM stock_log;and leave it open. - Run
VACUUM (VERBOSE) stock_log; it reports dead rows "not yet removable". - Planned mistake: disable autovacuum to "fix" growth; bloat gets worse. Fix: re-enable it.
- Terminate the idle session (or set
idle_in_transaction_session_timeout) and vacuum again; dead tuples drop. - Note table size stays large (reusable space, not returned to the OS).
Prepares MID-014-LAB1.
اختبر فهمك
Which message in VACUUM VERBOSE reveals the culprit?
أظهر الإجابة
Dead row versions "not yet removable" because of an old transaction.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.