PostgreSQL Enterprise (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What are `shared_buffers` and `work_mem` in PostgreSQL?
junior LevelDatabases & SQLPostgreSQL
In Simple Words:
shared_buffers: The primary memory cache where PostgreSQL caches table and index pages (typically set to 25% of total server RAM).work_mem: The amount of memory allocated per sort or hash operation per query (e.g.ORDER BY,DISTINCT, Hash Joins).- Crucial Sizing Note: If a query has 4 sort operations, it consumes $4 \times \text{work_mem}$! Sizing it too high across 500 connections triggers Linux Out-Of-Memory (OOM) killer.