postgres query doing a seq scan despite an index
Postgres 15. A query on orders(customer_id) is doing a sequential scan even though there's a btree index on customer_id. EXPLAIN ANALYZE:
Seq Scan on orders (cost=0.00..18334.00 rows=1 width=72) (actual time=0.02..120.3 rows=1 loops=1)
Filter: (customer_id = 4242)
Rows Removed by Filter: 500000
Planning Time: 0.08 ms
Execution Time: 120.4 ms
Why won't it use the index? The table has 500k rows.
4 replies