SpinTheMic
Pro

Interview practice question

Slow lookup query on an OLTP database

Data Engineering · SQL · Experienced

An application query on Postgres, filtering by customer_id and status and ordering by created_at, is slow on a 200 million row table. How do you fix it?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Check the plan with EXPLAIN ANALYZE.
  • A composite index on (customer_id, status, created_at) supports filter and sort.
  • Column order in the index matters: equality columns first, then sort column.
  • Avoid functions on indexed columns.
  • Consider partial indexes and keep stats updated.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics