Every tutorial tells you the same thing: add an index and the query gets faster. Most of the time that is true. But sometimes you add an index, or inherit one someone else added, and the query gets slower. I have seen this on production PostgreSQL databases more than once, and the first time it happened I assumed I had misread the timings. I had not. An index can make a query slower, and it helps to know the four ways it happens so you can spot which one you are looking at.
1. The planner picks the wrong index
PostgreSQL does not always choose the best plan. It chooses the plan it thinks is cheapest, based on table statistics. If those statistics are stale, the planner can pick an index scan for a query that would be faster as a sequential scan, for example when the query actually matches half the table. The giveaway is a plan that looks reasonable but runs slowly, with a big gap between the estimated rows and the actual rows.
Run ANALYZE on the table first. It is cheap and it refreshes the statistics the planner relies on. Then re-check the plan:
ANALYZE orders;
EXPLAIN ANALYZE SELECT * FROM orders WHERE status = 'shipped' AND created_at > now() - interval '30 days';
If the plan changes after ANALYZE, stale statistics were the problem. If you want the full method for reading these plans, I wrote about reading PostgreSQL EXPLAIN ANALYZE to find the slow query.
2. The index matches too many rows
An index is only useful when it narrows the search. An index on a boolean column, or a status column with three possible values, barely narrows anything. PostgreSQL still has to fetch most of the table, but now it does it through random index lookups instead of one efficient sequential scan. Random reads are slower than sequential reads, so the "optimized" query loses.
This is the classic low-selectivity problem. Before indexing a column, ask how many distinct values it has relative to the row count. A column with 50,000 distinct values in a table of 100,000 rows is selective. A column with 3 distinct values is not, and indexing it alone will not help a query that filters only on that column. A composite index that starts with a selective column is usually the better answer.
3. Writes pay for every index
Indexes do not slow down reads only. Every index on a table is a tax on writes. Each INSERT has to write a row to every index. Each UPDATE that touches an indexed column has to update that index too. On a table with eight indexes, a single row insert does nine writes instead of one.
This is easy to miss because the slowdown shows up far from the index: the queue worker that inserts webhook events gets slower, the import job that used to take two minutes takes nine, and nobody connects it to the index someone added last month "just in case". If a table is write-heavy, count its indexes and ask which ones any real query actually uses. PostgreSQL will tell you:
SELECT indexrelname, idx_scan
FROM pg_stat_user_indexes
WHERE relname = 'events'
ORDER BY idx_scan;
An index with an idx_scan of zero over weeks of traffic is dead weight. Drop it, preferably with DROP INDEX CONCURRENTLY so you do not lock the table.
4. Index bloat makes the index itself slow
PostgreSQL indexes accumulate dead entries when rows are updated or deleted. Autovacuum normally cleans them up, but on a busy table with long-running transactions it can fall behind. A bloated index is physically larger, so scanning it reads more pages from disk, and that cost grows quietly over months.
Check the size of an index against the table it serves:
SELECT pg_size_pretty(pg_relation_size('orders_status_idx')) AS index_size,
pg_size_pretty(pg_relation_size('orders')) AS table_size;
If the index is a large fraction of the table size on a table that churns heavily, bloat is a suspect. The fix is REINDEX CONCURRENTLY, which rebuilds the index without locking writes. Do it during a quiet window anyway, because it still costs I/O.
What to do when an index is the problem
Start with evidence, not instinct. Confirm with EXPLAIN ANALYZE that the index scan is actually the slow path, and compare it against the same query with the planner told to ignore index scans (SET enable_indexscan = off in your own session only, never in production config). If the sequential scan is faster, you have your answer. Then pick the right fix: refresh statistics with ANALYZE, drop a low-selectivity or unused index, replace a single-column index with a composite one, or rebuild a bloated index with REINDEX CONCURRENTLY.
One more habit worth keeping: measure before and after every index change on production-sized data. An index that helps on a local database with 200 rows can hurt on a table with 2 million. The timings on real data are the only opinion that counts.
Takeaway
Indexes are a trade-off, not a free speedup. They cost write performance, planner time, and disk, and they only pay that cost back when they are selective and actually used. When a query is slow, check whether the index is helping before you add another one. Sometimes the fastest fix is dropping the index that was supposed to make things faster.