Mladen Gogala wrote on 28.08.2010 00:43:
Quote:
It looks like the Postgres optimizer cannot use indexes for "order by"
conditions. The query that made me conclude this, looks like this: |
It sure can:
select id, prog_start, prog_end
from definition
order by id
QUERY PLAN
Index Scan using pk_def on definition (cost=0.00..21791.91 rows=372901 width=20)
Id is the PK for that table. If I order by a different column, the index is not used
QUERY PLAN
Sort (cost=48627.58..49559.83 rows=372901 width=20)
Sort Key: prog_end
-> Seq Scan on definition (cost=0.00..6471.01 rows=372901 width=20)
I would suspect the fact that your table is partitioned to be the reason for not using the index.
But I don't know how to overcome that.
Note that PostgreSQL cannot use "index-only" retrieval as Oracle can. Something that might change with 9.1
Thomas