Re: BUG #18778: Query planning fails in ExecInitExprRec with unrecognized node type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Zhang Mingli <zmlpostgres(at)gmail(dot)com>
Cc: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18778: Query planning fails in ExecInitExprRec with unrecognized node type
Date: 2025-01-18 16:51:37
Message-ID: 2550569.1737219097@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Zhang Mingli <zmlpostgres(at)gmail(dot)com> writes:
> And I have a question that may not be directly related to the issue: why is there a Subplan 2, and it appears to be unused?

Yeah, that's because the AlternativeSubPlan originally had two child
subplans: a parameterized one intended for a few calls, and a hashed
one to be used for a lot of calls. We build both because at the time
when this needs to happen, we don't have any clue how many calls
there will be. We wait till the very end of planning to decide which
one is more likely to win based on context, and then discard the
AlternativeSubPlan, replacing it with a direct reference to the chosen
SubPlan. But the other one stays in the tree. Getting rid of it
seemed complicated, and it won't be referenced at runtime so there's
not much penalty from leaving it there. It is confusing, I admit.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2025-01-19 01:12:09 Re: pg_rewind fails on Windows where tablespaces are used
Previous Message Zhang Mingli 2025-01-18 15:52:01 Re: BUG #18778: Query planning fails in ExecInitExprRec with unrecognized node type