Re: Would an index benefit select ... order by? - Mailing list pgsql-general

From Tom Lane
Subject Re: Would an index benefit select ... order by?
Date
Msg-id 14070.1194192541@sss.pgh.pa.us
Whole thread Raw
In response to Re: Would an index benefit select ... order by?  (rihad <rihad@mail.ru>)
List pgsql-general
rihad <rihad@mail.ru> writes:
> You mean Postgres wouldn't *always* use created_at's index with such
> access patterns on a big table (even if one exists):

> select * from foo order by created_at desc;

No, it wouldn't necessarily, and that's a good thing.  A full-table
indexscan can often be slower than a sort because of inefficient disk
access patterns.  The planner will estimate the cost of each possibility
and pick the one that looks cheaper.

            regards, tom lane

pgsql-general by date:

Previous
From: Reg Me Please
Date:
Subject: Re: COPY ... FROM and index usage
Next
From: Tom Lane
Date:
Subject: Re: COPY ... FROM and index usage