All Questions
Postgresql hard

How does the PostgreSQL query planner typically optimize a correlated subquery (e.g., `WHERE EXISTS (...)`) to prevent repetitive re-execution for every outer row?

  1. A It caches the result of the first N subquery executions in the L1 CPU cache to speed up subsequent hits.
  2. B It transforms the subquery into a more efficient 'Semi-Join' or 'Anti-Join' that uses set-level logic.
  3. C It offloads the subquery to a dedicated background worker thread that runs independently of the main plan.
  4. D It forces the query into a sequential scan to avoid the overhead of index-based nested loop lookups.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions