Re: Get rid of runtime handling of AlternativeSubPlan?

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2020-08-31T17:22:11Z
Lists: pgsql-hackers

Attachments

I wrote:
> One inefficiency I see that we could probably get rid of is
> where make_subplan() is doing
>             /* Now we can check if it'll fit in hash_mem */
>             /* XXX can we check this at the Path stage? */

I went ahead and fixed that, and I also realized there's another small
improvement to be made: we can remove the unused SubPlan from the
subplans list of the finished PlannedStmt, by setting that list cell
to NULL.  (This is already specifically allowed by the comments for
PlannedStmt.subplans.)  Initially I supposed that this'd only save the
costs of copying that subtree when we copy the whole plan.  On looking
closer, though, InitPlan actually runs ExecInitNode on every list
entry, even unused ones, so this will make some difference in executor
startup time.

Hence, an updated 0001 patch.  0002 hasn't changed.

			regards, tom lane

Commits

  1. Move resolution of AlternativeSubPlan choices to the planner.

  2. Arrange to convert EXISTS subqueries that are equivalent to hashable IN