Intermediate LevelPostgreSQL
What are SLRU (Simple LRU) caches and how do they manage subtransaction state?
❓ Interview Prompt: Explain SLRU (Simple Least Recently Used) caches, CLOG (transaction status), SUBTRANS (subtransactions), MULTIXACT, and SLRU lock contention.
PostgreSQL uses SLRU (Simple Least Recently Used) shared memory caches to track transaction metadata:
•
CLOG (Commit Log): Tracks transaction commit/abort status.
•
SUBTRANS: Tracks active subtransactions ('SAVEPOINT').
•
MULTIXACT: Tracks row-level shared lock multi-transactions.
Code Implementation Example
sql
-- Monitor SLRU cache stats via pg_stat_slru
SELECT name, blks_zeroed, blks_hit, blks_read, blks_written
FROM pg_stat_slru;💡Monitoring SLRU cache statistics via pg_stat_slru.
🎯 Interview Key Takeaway
Monitor pg_stat_slru to detect cache misses on CLOG and SUBTRANS shared memory buffers.
#SLRU#CLOG#SUBTRANS#Memory#Intermediate
Back to all PostgreSQL Questions→