Conditions that stop an index from being used
An index exists but is not used when the condition does not compare the indexed column itself. A B-tree narrows a range using the sorted order of values, so the thing being compared has to be the column value. These four shapes account for most of the cases seen in practice.
Leading wildcard
LIKE '%kim' gives no starting point, so no prefix of the index can be cut. The result is a full scan. LIKE 'kim%' narrows a prefix range and does use the index. When a search in the middle of a string is genuinely needed, a full-text index or a reversed index is the way.
-- no index use WHERE email LIKE '%@example.com' -- index can be used WHERE email LIKE 'kim@%'
A function around the column
WHERE LOWER(email) = 'kim@example.com' transforms the column value first, so a plain index cannot bound it. There are three options: normalise the value on write and compare WHERE email = 'kim@example.com', create an expression index such as CREATE INDEX ON users (LOWER(email)) and query with the same expression, or use a case-insensitive collation.
Arithmetic around the column
WHERE id + 1 = 42 is the same problem. The expression equals id = 41, so move the arithmetic to the constant side. Dates are just as common: WHERE date(created_at) = '2026-11-30' cannot use the index, while WHERE created_at >= '2026-11-30' AND created_at < '2026-12-01' can.
Implicit casts
Comparing a numeric column with a string literal makes the engine convert one side. PostgreSQL adapts the literal to the column type, but comparing a text column with a number puts a cast on the column and loses the index. Writing customer_id = '1042' out of habit becomes a problem when the code is ported.
Many OR conditions
For several values of the same column, IN (…) is better. An OR across different columns may still be combined from two indexes, but the estimate blurs as conditions grow and a full scan becomes likely. For a common combination, splitting into UNION ALL branches makes the plan predictable.
These warnings are signals read from the text, not measurements of a plan. Confirm with EXPLAIN before applying them, and remember that no warning does not prove an index was used.
Questions
What if a leading wildcard is unavoidable?
A full-text index (tsvector in PostgreSQL, FULLTEXT in MySQL) or a trigram index is the alternative. On a small table a full scan may be faster anyway.
When is an expression index worth it?
When the same expression is queried repeatedly. The index definition and the query expression must match exactly.
Does replacing OR with IN always help?
Usually when the same column is compared with several values. For different columns, compare UNION ALL against the original plan.
Paste the WHERE clause you suspect and the line that defeats the index is named for you.
Open the toolThis article follows the published documentation of PostgreSQL 17, MySQL 8.4 and SQLite 3.46. Every table, column and value shown is synthetic.