Greg Stark <gsstark(at)mit(dot)edu> writes:
> I recall there was a way to defeat this optimization involving introducing an
> extra subquery layer somewhere.
I think adding "OFFSET 0" to a subquery is the simplest way to prevent
it from being flattened.
regards, tom lane