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