System Design · medium

A model that ran in 2 minutes now takes 40. How do you diagnose and fix it?

Asked in Analytics Engineer interviews, in the System Design round.

Short answer

Check the query plan and the volume first: usually a full refresh where an incremental would do, a fan-out join from a non-unique key, or a missing partition/cluster filter. Fix by making it incremental, deduping the join key, or partitioning on the filter column. Measure before and after — it feels faster is not a diagnosis.

How to answer it

A twenty-fold slowdown is a change in the shape of the work, not a slow day on the warehouse. Find what changed before touching the SQL.

Diagnose, in order:

Then fix the cause you found:

Measure before and after, in the same units, and record it in the PR. "It feels faster" is not a diagnosis, and "it is 40 minutes because the data grew" is only acceptable if the row counts say so.

Related questions

Practice this for real