Code Room
Vibe codingHardvc-g106
Subject Ai code reviewLevel Senior–Staff~18 minCommon in Databases & SQL interviewsIndustries Technology, Software development

Question

To speed up a slow analytics query, an AI agent proposed and wrote this migration adding several indexes to a high-write `events` table (≈30k inserts/sec). Read latency on the dashboard improved, but a week later on-call is paged for rising write latency and replication lag.

sql
CREATE INDEX idx_events_user   ON events (user_id);CREATE INDEX idx_events_type   ON events (event_type);CREATE INDEX idx_events_region ON events (region);CREATE INDEX idx_events_status ON events (status);CREATE INDEX idx_events_source ON events (source);

Critique this both for the change mechanics and the design.

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.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.