Easy
SQL-O01sqlRead EXPLAIN — Index vs Full Scan
Problem
Given table `users(id PRIMARY KEY, email)` (10M rows), explain why `SELECT * FROM users WHERE id = 42` runs in microseconds while `SELECT * FROM users WHERE email = 'x@y.com'` is slow. What single change fixes the slow query?
Input
Conceptual.
Output
Explanation + DDL fix
Constraints
—
Sample input
—
Sample output
Add an index on email.
Explanation
PRIMARY KEY auto-creates a B-tree index. Lookups by email do a full table scan because email has no index.
optimisationindexes@Oracle
Visible test cases
in: explain
out: ok
Your solution — run it, use AI if stuck
sql
