Robert Haas <robertmhaas@gmail.com> writes:
> On Sun, Oct 16, 2011 at 4:46 AM, Kohei KaiGai <kaigai@kaigai.gr.jp> wrote:
>> I tried to reproduce the scenario with enough small from/join_collapse_limit
>> (typically 1), but it allows to push down qualifiers into the least scan plan.
> Hmm, you're right. LIMIT 1000000000 prevents qual pushdown, but
> hitting from_collapse_limit/join_collapse_limit apparently doesn't. I
> could have sworn I've seen this work the other way, but I guess not.
No, the collapse_limit variables are entirely unrelated to subquery
flattening, or to qual pushdown for that matter. They only restrict the
number of join paths we consider. And we will attempt to push down
quals into an unflattened subquery, too, if it looks safe. See
subquery_is_pushdown_safe, qual_is_pushdown_safe, etc in allpaths.c.
regards, tom lane