PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> switching the order of two columns make a SubqueryScan node to appear in
> the plan. It seems completely trivial as the cost is not modified, should it
> also be removed in the second case?
No. The SubqueryScan can only be optimized away if it makes no changes
in the result tuple.
Conceivably, with sufficiently complicated hacking in setrefs.c,
simple cases like column reordering could be handled there. But
I'm doubtful that it's worth the added cycles & risk of bugs.
regards, tom lane