Code RoomStale user deactivation performance
MediumPrep Room Coding #4405

Stale user deactivation performance

Vibe & agenticDatabases & SQLMid–Senior~16 min

An AI wrote this Django management command to deactivate users who haven't logged in for a year. It runs nightly. On a 2-million-user table it takes hours and hammers the primary DB. Identify the inefficiency and rewrite it.

Implement
count_write_statements(stale_user_count: int, audit_batch_size: int, use_bulk_writes: bool) → int
Examples
in[200000,5000,true]out41
in[200000,5000,false]out400000
in[50,5000,true]out2
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 16 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.