Bird
0
0

You set work_mem to '100MB' but notice queries still perform slow external sorts. What is a likely cause?

medium📝 Debug Q6 of 15
PostgreSQL - Performance Tuning
You set work_mem to '100MB' but notice queries still perform slow external sorts. What is a likely cause?
AThe <code>effective_cache_size</code> is too high causing planner confusion
BThe <code>work_mem</code> setting was not applied because of missing quotes
CThe query uses multiple sorts, each limited to 100MB, but total memory is insufficient
DThe disk is too fast, causing PostgreSQL to prefer external sorts
Step-by-Step Solution
Solution:
  1. Step 1: Analyze memory per sort

    Each sort can use up to 100MB, but multiple sorts multiply memory needs.
  2. Step 2: Understand total memory usage

    If total memory for all sorts exceeds available RAM, external sorts still occur.
  3. Final Answer:

    The query uses multiple sorts, each limited to 100MB, but total memory is insufficient -> Option C
  4. Quick Check:

    Multiple sorts multiply work_mem needs [OK]
Quick Trick: Check total memory for all sorts, not just one [OK]
Common Mistakes:
  • Assuming one sort uses all work_mem
  • Ignoring multiple sort operations
  • Blaming effective_cache_size for sort memory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes