Code RoomIndexes degrade write performance
HardPrep Room Coding #4068

Indexes degrade write performance

Vibe & agenticDatabases & SQLSenior–Staff~18 min

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.

Critique this both for the change mechanics and the design.

Implement
build_index_plan(table: str, index_lines: list[str], row_count: int) → list[str]
Examples
in["events",["idx_events_user|user_id|4000000","idx_events_status|status|3"],100000000]out["CREATE INDEX CONCURRENTLY idx_events_user ON events (user_id);"]
in["events",["idx_events_user|user_id|4000000","idx_events_type|event_type|12","idx_events_region|region|8","idx_events_status|status|4","idx_events_source|source|6"],100000000]out["CREATE INDEX CONCURRENTLY idx_events_user ON events (user_id);"]
in["events",["idx_a|user_id|5000000","idx_b|user_id|5000000"],1000000]out["CREATE INDEX CONCURRENTLY idx_a ON events (user_id);"]
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 18 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.