Re: Query optimizing - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Query optimizing
Date
Msg-id 491829EA.1060106@archonet.com
Whole thread Raw
In response to Re: Query optimizing  ("Sebastian Ritter" <ritter.sebastian@gmail.com>)
Responses Re: Query optimizing
List pgsql-sql
Sebastian Ritter wrote:
> Could it have something
> to do with the fact that it is a subquery and thus the planner can not
> deduce filtering conditions from the outer query against it? My apologises
> if that made no sense.

Could make a difference.

> In summary, what im trying to understand is the following: Will there be a
> performance difference between filtering query sets first and then joining
> them together as opposed to joining first and then filtering? Does the
> opitmiser not choose the best course of action either way yielding the same
> result?

There obviously is a performance difference between joining all of the
issues table versus joining 1% of it to followups.

In most cases the planner can push the condition into the subquery, but
not in all cases because:1. It's not provably correct to do so2. The planner isn't smart enough to figure out that it
can

It's impossible to say which applies to you without knowing the full query.

--  Richard Huxton Archonet Ltd


pgsql-sql by date:

Previous
From: "Sebastian Ritter"
Date:
Subject: Re: Query optimizing
Next
From: "Sebastian Ritter"
Date:
Subject: Re: Query optimizing