Say I have:
select foo ( select foo from bar1 union all select foo from bar2 union all select foo from bar3 ...) a order by foo desc limit X;
(and I can give you few other examples around the same 'note', say with when foo=N in outer subselect)
Would anyone consider such optimization, when postgres will apply the same condition to inner queries, providing that their size is substantial?
Same would actually apply for different subqueries, without union/ intersect/etc:
select foo( select foo from bar1 ) a where foo in (x,y,z) order by foo desc limit N
(of course this is just a simplified example).