All jobs / Backend developer / Performance
Backend developer interview question · 3–5 years
The interviewer asks: “This query is slow in production but fine on your laptop. What do you do first?” Strongest answer?
The strongest answer
Get the production plan (EXPLAIN ANALYZE / actual plan from the store). Compare row estimates, look for seq scans, nested loops on big sets, and stale stats — don't rewrite blindly.
Why it works
Exactly. The laptop has different stats, cache and data shape. The plan is the artefact. Then you fix stats, the predicate, or one index.
What a good answer covers
- Read the production plan first.
- Estimates vs actuals, scans vs seeks.
- Fix stats/predicate/index — not folklore.
- Don't copy prod PII onto a laptop.
Answers that fall short
- Close, but not the strongest: Add four indexes that match every column in the query.
Spray-indexing slows writes and may still miss a sargability bug. Plan first. - Weak: Copy production data to my laptop and time it there.
Copying prod to a laptop is often a privacy violation and still not the same hardware. Use a sanitised snapshot in a safe env if you must replay. - Red flag: SELECT * into a temp table first so the planner has a simpler job.
Temp-table gymnastics can help a specific case after you understand the plan — not as the opening move, and never as SELECT *.
Who gets asked this
More Performance questions
- An endpoint takes 1.5 seconds at p95. The container’s CPU sits at 8% and the CPU profiler shows almost…
- The interviewer asks: “The cache expires and 2,000 requests hit the database at once. How do you prevent…
- Under load, someone raises the connection pool from 20 to 200 per instance. Throughput drops and p95 gets…
- The interviewer asks: “How do you know we can take 3× traffic on Monday?” Strongest answer?
- The interviewer asks: “The bill doubled but QPS didn't. Where do you look?” Strongest answer?
- A teammate opens a pull request that rewrites a service “for performance”. What do you ask for before you…
- The interviewer asks: “The API is idle but requests hang on 'opening a connection.' What's going on?”…
- The interviewer asks: “The API returns 429. What should a client do?” Strongest answer?