Why is my Oracle query slow? Seven common causes
Most slow Oracle queries are slow for one of a handful of reasons, and most of them show in the execution plan. Here they are, each with the fix.
1. A function on an indexed column
An index on ORDER_DATE cannot be used when the column is wrapped in a function: Oracle has to compute TRUNC for every row.
-- Slow: TRUNC on the column hides it from its index
select * from orders where trunc(order_date) = date '2026-03-01';
-- Fast: compare the column itself with a range
select * from orders
where order_date >= date '2026-03-01'
and order_date < date '2026-03-02';2. An implicit conversion
When a VARCHAR2 column is compared with a number, Oracle converts the column, row by row, and the index is not used. Compare with a value of the column's own type.
-- PHONE_NO is VARCHAR2: this converts every row with TO_NUMBER
select * from customers where phone_no = 5550123;
-- Use a string
select * from customers where phone_no = '5550123';3. A leading wildcard
LIKE '%son' cannot use a normal index, because the start of the value is unknown. LIKE 'Ander%' can. For searches inside text, consider Oracle Text.
4. NOT IN on a column that can be NULL
NOT IN returns no rows at all when the subquery returns a NULL, and it often prevents a good anti-join. NOT EXISTS is both correct and usually faster.
select c.customer_id, c.name
from customers c
where not exists (select 1 from orders o where o.customer_id = c.customer_id);5. OR across different columns
A condition like status = 'OPEN' OR region_id = 5 often turns into a full scan. Two queries joined with UNION ALL (excluding the overlap) can each use their own index.
6. Missing or stale statistics
The optimizer chooses a plan from the statistics. When a table grew a lot since they were gathered, its estimates are wrong. Check LAST_ANALYZED and gather them again.
select table_name, num_rows, last_analyzed from user_tables where table_name = 'ORDERS';
begin
dbms_stats.gather_table_stats(ownname => user, tabname => 'ORDERS');
end;
/7. A correlated subquery run for every row
A scalar subquery in the select list (the latest order of each customer, say) runs once per row. A join to an aggregated inline view, or an analytic function such as MAX() OVER, reads the table once.
Find the cause in seconds with Felix
In Felix, put the caret in the query and press Ctrl+Shift+Q (Optimize with AI). It reads the execution plan and the tables' statistics and indexes, names the causes above with the plan line, writes a faster query with the same result, and shows the estimated cost before and after. The model runs on your PC: your SQL is not sent anywhere.
More about it: AI query optimizer for Oracle in Felix.
Try it on your own database
Felix is a Windows IDE for Oracle SQL and PL/SQL, from 11g to 23ai. Every feature is in the free 30-day trial; no account needed.