팽창 진단 및 진공 전략
MVCC가 테이블과 인덱스 팽창을 일으키는 방식과 이를 측정하는 방법, 그리고 높은 성능을 유지하도록 자동 진공을 조정하는 방법을 이해해 보세요.
팽창 진단 및 진공 전략은(는) CoddyKit의 무료 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Advanced PostgreSQL: Indexing, Partitioning, Replication 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
MVCC and Dead Tuples
PostgreSQL uses MVCC: updates and deletes leave behind old row versions called dead tuples. Until they are cleaned up, they occupy space and slow scans. This wasted space is bloat.
What VACUUM Does
VACUUM reclaims dead tuples for reuse and updates visibility information. It usually does not return space to the OS; VACUUM FULL does but rewrites the whole table and takes a strong lock.
Measuring Bloat
Inspect dead tuple counts per table from the statistics view.
SELECT relname, n_live_tup, n_dead_tup,
last_autovacuum
FROM pg_stat_user_tables
ORDER BY n_dead_tup DESC;Autovacuum Basics
Autovacuum runs in the background, triggering when dead tuples exceed a threshold based on table size and the scale factor setting.
-- trigger ~ threshold + scale_factor * n_live_tup
autovacuum_vacuum_scale_factor = 0.2Tuning Hot Tables
For large, frequently updated tables, the default 20% scale factor is too lazy. Lower it per table so vacuum runs more often on less garbage.
ALTER TABLE orders SET (
autovacuum_vacuum_scale_factor = 0.02);Vacuum Throttling
Autovacuum throttles itself with cost limits to avoid I/O storms. On modern hardware you can raise autovacuum_vacuum_cost_limit so vacuum finishes faster.
autovacuum_vacuum_cost_limit = 2000Transaction ID Wraparound
VACUUM also prevents transaction ID wraparound, a catastrophic condition. Aggressive anti-wraparound vacuums are non-negotiable and cannot be skipped.
SELECT datname, age(datfrozenxid)
FROM pg_database ORDER BY 2 DESC;Index Bloat
Indexes bloat too. REINDEX CONCURRENTLY rebuilds an index without blocking writes, restoring its compactness.
REINDEX INDEX CONCURRENTLY orders_pkey;HOT Updates
Heap-Only Tuple updates avoid index churn when no indexed column changes. Leaving some free space via a lower fillfactor helps HOT updates and reduces bloat.
ALTER TABLE orders SET (fillfactor = 90);VACUUM vs ANALYZE
VACUUM reclaims space; ANALYZE refreshes the planner statistics. Autovacuum does both, but after big bulk loads run ANALYZE manually for fresh plans.
ANALYZE orders;A Monitoring Habit
Alert on rising n_dead_tup, growing table size with stable row counts, and high age(datfrozenxid). These early signals let you tune before queries slow down.
Quick Check
A large, hot table keeps growing despite stable row counts. What is the likely cause and fix?
Recap
You learned to diagnose bloat from MVCC dead tuples, measure it with pg_stat_user_tables, tune autovacuum per table, guard against ID wraparound, and use REINDEX CONCURRENTLY and fillfactor to keep performance high.
AI 튜터와 함께 Advanced PostgreSQL: Indexing, Partitioning, Replication을(를) 배우세요 — 무료
브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.
- 코스
- 11
- 레슨
- 44
자주 묻는 질문
“팽창 진단 및 진공 전략” 강의는 무료인가요?
네 — “팽창 진단 및 진공 전략” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의 전체를 잠금 해제할 수 있습니다. Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에는 총 4개의 강의가 포함되어 있습니다.
“팽창 진단 및 진공 전략”에서 뭘 배우나요?
MVCC가 테이블과 인덱스 팽창을 일으키는 방식과 이를 측정하는 방법, 그리고 높은 성능을 유지하도록 자동 진공을 조정하는 방법을 이해해 보세요. 브라우저에서 직접 실행하는 실습 코드로 Advanced PostgreSQL: Indexing, Partitioning, Replication을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Advanced PostgreSQL: Indexing, Partitioning, Replication을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Advanced PostgreSQL: Indexing, Partitioning, Replication은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“팽창 진단 및 진공 전략” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Advanced PostgreSQL: Indexing, Partitioning, Replication 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 종합적인 성능 튜닝
- 고급 모니터링 및 알림
- PostgreSQL의 미래 동향
- 팽창 진단 및 진공 전략