Re: A cost issue in ORDER BY + LIMIT - Mailing list pgsql-hackers

From Tom Lane
Subject Re: A cost issue in ORDER BY + LIMIT
Date
Msg-id 102404.1659802376@sss.pgh.pa.us
Whole thread Raw
In response to A cost issue in ORDER BY + LIMIT  (Paul Guo <paulguo@gmail.com>)
List pgsql-hackers
Paul Guo <paulguo@gmail.com> writes:
> Postgres seems to always optimize ORDER BY + LIMIT as top-k sort.
> Recently I happened to notice
> that in this scenario the output tuple number of the sort node is not
> the same as the LIMIT tuple number.

No, it isn't, and your proposed patch is completely misguided.
The cost and rowcount estimates for a plan node are always written
on the assumption that the node is run to completion.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: `make check` doesn't pass on MacOS Catalina
Next
From: Tom Lane
Date:
Subject: conchuela doesn't like gnu_printf anymore