View Single Post

   
  #12 (permalink)  
Old 05-07-2008, 06:21 PM
Matthew Wakeling
 
Posts: n/a
Default Re: multiple joins + Order by + LIMIT query performanceissue

On Tue, 6 May 2008, Tom Lane wrote:
> If a misestimate of this kind is bugging you enough that you're willing
> to change the query, I think you can fix it like this:
>
> select ... from foo order by x limit n;
> =>
> select ... from (select ... from foo order by x) ss limit n;
>
> The subselect will be planned without awareness of the LIMIT, so you
> should get a plan using a sort rather than one that bets on the LIMIT
> being reached quickly.


Surely if that's the case, that in itself is a bug? Apart from being
"useful", I mean.

Matthew

--
"Television is a medium because it is neither rare nor well done."
-- Fred Friendly

--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Reply With Quote