SQL function prevents index use
An AI assistant wrote this query to find recent failed logins by email domain. There's a btree index on `created_at` and one on `email`. The query is correct but does a full table scan on a 500M-row table and takes 40 seconds.
Why can't the existing indexes be used, and how do you make it fast?
Implement
check_sargability(predicates: list[str]) → list[str]Examples
in
[["DATE(created_at) = CURRENT_DATE","LOWER(email) LIKE '%@acme.com'","status = 'failed'"]]out["function_on_column","function_on_column","sargable"]in
[["created_at >= CURRENT_DATE","email LIKE '%@acme.com'","email LIKE 'acme%'"]]out["sargable","leading_wildcard","sargable"]in
[[]]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 15 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.