Re: Proposed patch for qual pushdown into UNION/INTERSECT - Mailing list pgsql-patches

From Tom Lane
Subject Re: Proposed patch for qual pushdown into UNION/INTERSECT
Date
Msg-id 3577.1030634699@sss.pgh.pa.us
Whole thread Raw
In response to Re: Proposed patch for qual pushdown into UNION/INTERSECT  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-patches
Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> I do wonder if queries like
> select * from ((select * from bar1 union all select * from bar2
> union all (select * from bar1 except select * from bar2)) intersect select
> * from bar1) as foo where a>4;

> can push the a>4 restriction into the right side of the intersect which it
> doesn't seem to right now,

Not without a lot more work, which I haven't got time for now.

> We could probably do:
> Subquery
>  Intersect
>   Append
>    Subquery (passing down a>4)
>    Subquery (passing down a>4)
>    <something> (filter a>4)
>     Except
>      Subquery
>      Subquery
>   Subquery (passing down a>4)
> and get the same effect,

Yeah, the problem is the planner doesn't currently cope with attaching
quals to intermediate levels of a set-op tree, so there's no way to
do the above.

> but I think
> the mixed case is probably rare enough
> to not worry about for now.

Agreed.  This is still a step forward.

            regards, tom lane

pgsql-patches by date:

Previous
From: Manfred Koizar
Date:
Subject: Re: Visibility regression test
Next
From: Tom Lane
Date:
Subject: Re: Visibility regression test