Re: order by and index path (was: What about LIMIT in SELECT ?) - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: order by and index path (was: What about LIMIT in SELECT ?)
Date
Msg-id 362601CC.AA5032C2@trust.ee
Whole thread Raw
List pgsql-hackers
> Date: Thu, 15 Oct 1998 10:56:50 +0200
Andreas Zeugswetter wrote:
>
> Resumee:
> You have to look at this from the cost point of view. If there is an order by that can be
> done with an index, this will make the index a little more preferrable than for the same
> query without the order by, but it should not force the index.
> You have to give the sort a cost, so that the index access can be compared to the
> seq scan and sort path.

But if we finally get only 10 first rows, it may still be _much_ faster
to do just the index scan, which, being the toplevel executor will get
only the needed rows.

So here we come back to the LIMIT clause (or something like it) because
the optimiser has no knowledge whatever about the use of DECLARE/FETCH
(I assume).



------------------
Hannu Krosing

pgsql-hackers by date:

Previous
From: Andreas Zeugswetter
Date:
Subject: AW: [HACKERS] PostgreSQL v6.4 BETA2...
Next
From: Brook Milligan
Date:
Subject: Re: [HACKERS] perl interface bug?