| From: | Chris <chris(at)bitmead(dot)com> |
|---|---|
| To: | pgsql-hackers(at)postgreSQL(dot)org |
| Subject: | Re: [HACKERS] Solution for LIMIT cost estimation |
| Date: | 2000-02-13 12:07:03 |
| Message-ID: | 38A69E67.AB2944D0@bitmead.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Tom Lane wrote:
>
> SELECT * FROM table WHERE x > 100 ORDER BY x LIMIT 1;
Could it _ever_ be faster to sort the tuples when there is already an
index that can provide them in sorted order?
>
> to get the tuple with lowest x > 100. Assuming that there is an index
> on x, the right way to implement this is with an indexscan, because a
> single probe into the index will pull out the tuple you want. But right
> now the optimizer will choose a plan as if the LIMIT weren't there,
> ie on the basis of estimated total cost to retrieve the whole ordered
> result set. On that basis it might well choose sequential scan + sort,
> so you'd have to wait around for a sort to complete before you get your
> answer.
>
> regards, tom lane
--
Chris Bitmead
mailto:chris(at)bitmead(dot)com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chris | 2000-02-13 12:29:34 | Re: [HACKERS] libpq |
| Previous Message | Billy G. Allie | 2000-02-13 05:52:36 | Problems compiling latest CVS sources. |