Re: Planner Conceptual Error when Joining a Subquery -- Outer Query Condition not Pulled Into Subquery

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gavin Wahl <gavinwahl(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Planner Conceptual Error when Joining a Subquery -- Outer Query Condition not Pulled Into Subquery
Date: 2013-10-16 08:28:44
Message-ID: 7176.1381912124@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Gavin Wahl <gavinwahl(at)gmail(dot)com> writes:
> It'd be nice if the planner could optimize the query (1) by turning it
> into (2). I understand that it might not be able to, but if it can pull
> the condition up in (3), why can't it in (4)?

(3) is an instance of seeing "a = b and b = c" and deducing "a = c" from
that. (4) does not follow that pattern, so it's outside the realm of
what the planner can deduce.

In principle we could take "a = b and (b = c or b = d)" and deduce
"a = c or a = d" from that, but it'd be a lot more complication for a
lot less benefit than what we get from the existing logic.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Gavin Wahl 2013-10-17 02:45:12 Re: Planner Conceptual Error when Joining a Subquery -- Outer Query Condition not Pulled Into Subquery
Previous Message Ken Tanzer 2013-10-16 07:20:09 Re: BASH script for collecting analyze-related info