You added an index, but the query is still slow. The database may be ignoring the index completely and reading every row. Here are the five most common reasons, and how to fix each one.
I checked every query plan below in SQLite on a 100,000-row table. The same rules apply to PostgreSQL and MySQL.
Video version:
First: ask the database with EXPLAIN
Don't guess. Put EXPLAIN in front of the query ( EXPLAIN QUERY PLAN in SQLite, EXPLAIN or EXPLAIN ANALYZE in Postgres and MySQL):
EXPLAIN QUERY PLAN SELECT * FROM users WHERE email = '[email protected]' ; SEARCH users USING INDEX idx_email ( email =? ) β
index used
EXPLAIN QUERY PLAN SELECT * FROM users WHERE DATE ( created_at ) = '2025-06-01' ; SCAN users β reads every row
Enter fullscreen mode
Exit fullscreen mode
SEARCH β¦ USING INDEX (or Index Scan in Postgres) means the index is working. SCAN (or Seq Scan ) means a full table scan.
1.β¦