SQL, indexing and PostgreSQL interview questions

B-tree and other index types, reading EXPLAIN, N+1 queries, upserts, pagination, NULL rules, pooling and migrations that don't lock production.

5 quick facts

– interview-ready · 14 questions in this topic

– of 14 tried

Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.

Questions

  1. How a B-tree index speeds up a queryPick the fix
  2. Column order in a composite indexPick the fix
  3. Index-only scans and INCLUDEFill the blank
  4. Reading EXPLAIN ANALYZEOrder the steps
  5. B-tree, GIN, GiST, BRIN and hashPick the fix
  6. Partial and expression indexesPredict
  7. The N+1 query problemSpot the bug
  8. Upserts with ON CONFLICTPredict
  1. OFFSET vs keyset paginationPredict
  2. NULL, three-valued logic and NOT INPredict
  3. Window functionsPredict
  4. Normalization and when to denormalizePick the fix
  5. Connection pooling and PgBouncerPick the fix
  6. Schema changes without downtimeOrder the steps

Practise this topic

Flashcards · 19

Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.

Quick quiz · 14 questions

One exercise per question, checked as you go. Needs JavaScript.

Mock interview · 2 sets

Timed, out loud, then tick what you covered. Needs JavaScript.

Fix this PR · 1 review

Review a diff like a senior: flag the lines you'd comment on. Needs JavaScript.

Quick facts

Recall the answer first, then tap Show to check.

Sources: Topic outline informed by System Design Primer by Donne Martin and the Zalando RESTful API Guidelines, both licensed under CC BY 4.0. Every question and answer is written by Best Latest Apps. Credits and license