On 2020-Mar-22, James Coleman wrote: > One question I have while I work on that: I've noticed some confusion > in the patch as to whether we should refer to the node below the > incremental sort node in the plan tree (i.e., the node we get tuples > from) as the inner node or the outer node. Intuitively I'd expect to > call it the inner node, but the original patch referred to it > frequently as the outer node. The outerPlanState/innerPlanState macro > comments don't offer a lot of clarification though they're "to avoid > confusion" about right/left inner/outer. I suppose if the > outerPlanState macro is working here the correct term should be outer?
I think the inner/outer distinction comes from join nodes wanting to distinguish which child drives the scan of the other. If there's a single child, there's no need to make such a distinction: it's just "the child". And if it's the only child, conventionally we use the first one, which conventionally is (for us westerners) the one on the left. This view is supported by the fact that outerPlanState() appears 113 times in the code whereas innerPlanState() appears only 27 times -- that is, all plan types that use only one child use the outer one. They could use either, as long as it does that consistently, I think. Therefore the term should be "outer". It's not "outer" to the parent incremental sort; it's just the "outer" of its two possible children. I think. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services