ORM migration generates inefficient queries
You're migrating a data-access layer from hand-written SQL to an ORM (e.g. raw psycopg queries to SQLAlchemy ORM) and an AI agent does most of the translation. Functionally the endpoints return identical JSON and all tests pass, but a week after rollout, p99 latency and DB load have crept up. What did the agent most likely do, and how should you have verified equivalence before shipping?
Implement
detect_n_plus_one(query_log: list[str], threshold: int) → list[str]Examples
in
[["SELECT * FROM orders WHERE id = 1","SELECT * FROM items WHERE order_id = 1","SELECT * FROM items WHERE order_id = 2","SELECT * FROM items WHERE order_id = 3"],3]out["SELECT * FROM items WHERE order_id = ?"]in
[["SELECT * FROM orders o JOIN items i ON i.order_id = o.id"],2]out[]in
[[],2]out[]What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.
0:00 of about 24 min
Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.