Lab 09: PostgreSQL WAL & MVCC
Overview
Step 1: WAL Configuration and pg_wal Directory
docker run -d --name pg-lab \
-e POSTGRES_PASSWORD=rootpass \
postgres:15 \
-c wal_level=replica \
-c max_wal_size=1GB \
-c min_wal_size=80MB \
-c checkpoint_completion_target=0.9 \
-c wal_compression=on
sleep 12
# Check WAL directory
docker exec pg-lab ls -la /var/lib/postgresql/data/pg_wal/ | head -10
echo ""
# Check WAL settings
docker exec pg-lab psql -U postgres -c "
SELECT name, setting, unit
FROM pg_settings
WHERE name IN (
'wal_level', 'max_wal_size', 'min_wal_size',
'checkpoint_completion_target', 'wal_compression',
'checkpoint_timeout', 'wal_segment_size'
);
"Step 2: WAL Functions — Track WAL Position
Step 3: MVCC — xmin and xmax System Columns
Step 4: Observe MVCC with Concurrent Updates
Step 5: VACUUM and AUTOVACUUM
Step 6: EXPLAIN Shows Heap Fetches (MVCC Cost)
Step 7: Transaction ID Wraparound Protection
Step 8: Capstone — WAL + MVCC Health Check
Summary
Concept
Location/Tool
Key Detail
Key Takeaways
Last updated
