"Ron Johnson" <ron.l.johnson@cox.net> writes:
>> The main disadvantage is that it's not clear when it would actually be faster.
>> Generally index scans are slower than reading the whole table and sorting.
>> Probably it would have to run an SPI query to use the planner to find the best
>> way to get the rows it wants.
>
> I believe you, but it's totally counter to prima-fascia logic.
>
> Scanning the whole table means that you have to read in a whole
> bunch of columns that you don't really give a rat's arse about, and
> thus is a waste, whereas directly reading an existing index means
> that you've got perfect locality of data, since you're only reading
> what you care about.
Well you still have to read the table either way. The main difference is
you'll end up reading it in a random access order which is slower and also
means potentially reading parts of it many times over before you're done.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com