Dent John <de...@qqdd.eu> writes: > However, if I factor back in the cost of the InitPlan, things net out much > more in favour of a scan against the MV. Of course, the add_path() comparison > logic doesn’t include the InitPlan cost, so the point is moot.
Please explain yourself. InitPlans will, as a rule, get stuck into the same place in the plan tree regardless of which paths are chosen; that's why we need not consider them in path cost comparisons. Moreover, once the initplan's own subplan is determined, it's going to be the same regardless of the shape of the outer query --- so if we did factor it in, it'd contribute the same cost to every outer path, and thus it still wouldn't change any decisions. So I don't follow what you're on about here. regards, tom lane