Code Room
System designMediumsd-g041
Subject Secondary indexesLevel Mid–Senior~35 minCommon in Databases & SQL interviewsIndustries Technology, Software development

Question

A project-management app's 'my open issues, sorted by updated-at' query is slow: it filters by (assignee_id, status='open') and sorts by updated_at, over a 500M-row issues table, and shows 50 rows per page. The query currently filters on an index but then does 50 random heap fetches per page and re-sorts. p95 is 400ms; target 50ms. Reads vastly outnumber writes but writes are frequent (issues update often). Design the indexing fix, explain why it works, and the cost you're accepting.

What a strong answer looks like

Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts — data model, bottlenecks, consistency, failure modes — and name the trade-offs you are making.

Narrate your design
Loading whiteboard…
Run or narrate your approach, then ask the coach.