Greg Stark <gsstark(at)mit(dot)edu> writes:
> Shouldn't Postgres be noticing the non-immutable random() function and not
> making the subquery an InitPlan?
Perhaps. In the dim past, using a dummy subquery was the only way to
persuade the planner not to re-evaluate functions that you didn't want
evaluated more than once, so changing this could be expected to break
some existing applications. Barring some non-invented cases where it
causes problems, I'm inclined to leave it alone.
regards, tom lane