Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: Performance & internals
Stage 5: Specialization

Part 18 / Topic 7 of 7

Configuration: the first look

Tuning queries beats tuning knobs — but four settings are checked first on every new server, because the defaults assume a tiny machine:

Setting Default First-look guidance
shared_buffers 128MB ~25% of RAM on a dedicated server
work_mem 4MB Raise modestly (remember: per operation × per connection); raise per-session for known big sorts
effective_cache_size 4GB ~50–75% of RAM — advice to the planner about OS cache, allocates nothing
random_page_cost 4.0 1.1 on SSDs — the 4.0 assumes spinning disks and scares the planner off indexes
SELECT name, setting, unit
FROM pg_settings
WHERE name IN ('shared_buffers', 'work_mem', 'effective_cache_size', 'random_page_cost')
ORDER BY name;
         name         | setting | unit 
----------------------+---------+------
 effective_cache_size | 524288  | 8kB
 random_page_cost     | 4       | 
 shared_buffers       | 16384   | 8kB
 work_mem             | 4096    | kB
(4 rows)

random_page_cost deserves its sentence: it encodes "random reads cost 4× sequential" — true of hard disks, false of SSDs. On flash storage, lowering it to ~1.1 is often the single config change that flips stubborn seq scans into the index scans you expected. Everything beyond these four: measure first (sections 1 and Part 16), change one thing, measure again — the method is the tuning.

🧪 Quick quiz — answer from memory, then check.

  1. Which setting allocates no memory yet changes plans?
  2. Why lower random_page_cost on SSDs?
Show the answers
  1. effective_cache_size — a planner hint about the OS cache.
  2. The 4.0 default models spinning-disk seeks; SSDs make random reads nearly sequential-cheap, and the honest ratio makes index plans win where they should.

Done here? The practice set for Part 18 — 5 exercises with solutions — is on the part page.

Search the guide