Re: Limit + group + join

From: Merlin Moncure
Subject: Re: Limit + group + join
Date: ,
Msg-id: 6EE64EF3AB31D5448D0007DD34EEB3417DD1F1@Herge.rcsinc.local
(view: Whole thread, Raw)
In response to: Limit + group + join  (Tobias Brox)
List: pgsql-performance

Tree view

Limit + group + join  (Tobias Brox, )
 Re: Limit + group + join  ("Jeffrey W. Baker", )
  Re: Limit + group + join  (Tobias Brox, )
  Re: Limit + group + join  ("Jeffrey W. Baker", )
 Re: Limit + group + join  (Mark Kirkwood, )
  Re: Limit + group + join  (Tobias Brox, )
  Re: Limit + group + join  (Stephan Szabo, )
  Re: Limit + group + join  (Tom Lane, )
   Re: Limit + group + join  (Mark Kirkwood, )
    Re: Limit + group + join  (Tom Lane, )
   Re: Limit + group + join  (Mark Kirkwood, )
    Re: Limit + group + join  (Tom Lane, )
     Re: Limit + group + join  (Mark Kirkwood, )
      Re: Limit + group + join  (Tobias Brox, )
   Re: Limit + group + join  (Greg Stark, )
 Re: Limit + group + join  ("Merlin Moncure", )
 Re: Limit + group + join  ("Merlin Moncure", )

Mark Kirkwood
> > The 'desc' seems to be the guy triggering the sort, e.g:
>
> Oh; really an accident that I didn't notice myself, I was actually
going
> to
> remove all instances of "desc" in my simplification, but seems like I
> forgot.

If desc is the problem you can push the query into a subquery without
sorting and sort the result.  This is called an inline view.  Sometimes
you can pull a couple of tricks to force the view to materialize before
it is sorted.

aka
select q.*
from
(
   some_complex_query
) q order by ...;

Merlin


pgsql-performance by date:

From: Bruno Wolff III
Date:
Subject: Re: How does the planner execute unions?
From: Arjen van der Meijden
Date:
Subject: Re: Inefficient queryplan for query with intersectable