postgres EXPLAIN shows index scan but query still slow
Postgres 15. EXPLAIN ANALYZE for a report query shows it's using the right index, but the query takes 8 seconds:
Index Scan using events_ts_idx on events (cost=0.43..52000.00 rows=100000 width=64) (actual time=0.03..7900.00 rows=100000 loops=1)
Index Cond: (ts >= '2026-01-01'::date)
Buffers: shared hit=98000
It fetches 100k rows. Is the index scan itself the problem, or is it something else? Been going in circles on this for a day.
4 replies