Re: Slow query with join - Mailing list pgsql-general

From Tom Lane
Subject Re: Slow query with join
Date
Msg-id 8884.1426539996@sss.pgh.pa.us
Whole thread Raw
In response to Re: Slow query with join  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Responses Re: Slow query with join
List pgsql-general
Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
> On 16.3.2015 19:50, Marc Watson wrote:
>> I hope someone can help me with a problem I'm having when joining a
>> view with a table. The view is somewhat involved, but I can provide the
>> details if necessary

> First, get rid of the ORDER BY clauses in the subselects - it's
> completely pointless, and might prevent proper optimization (e.g.
> replacing the IN() with optimized joins.

I'm suspicious that the cause may be an ORDER BY in the view.  It's
hard to tell when we've not seen the view definition, but I see that both
plans we've been shown are going to produce output sorted by actor.id.
Maybe that's happenstance, or maybe not.

            regards, tom lane


pgsql-general by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Slow query with join
Next
From: "David G. Johnston"
Date:
Subject: How does one make the following psql statement sql-injection resilient?