Allowing parallel-safe initplans

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Allowing parallel-safe initplans
Date: 2023-04-12 16:43:52
Message-ID: 1129530.1681317832@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Pursuant to the discussion at [1], here's a patch that removes our
old restriction that a plan node having initPlans can't be marked
parallel-safe (dating to commit ab77a5a45). That was really a special
case of the fact that we couldn't transmit subplans to parallel
workers at all. We fixed that in commit 5e6d8d2bb and follow-ons,
but this case never got addressed.

Along the way, this also takes care of some sloppiness about updating
path costs to match when we move initplans from one place to another
during createplan.c and setrefs.c. Since all the planning decisions are
already made by that point, this is just cosmetic; but it seems good
to keep EXPLAIN output consistent with where the initplans are.

The diff in query_planner() might be worth remarking on. I found
that one because after fixing things to allow parallel-safe initplans,
one partition_prune test case changed plans (as shown in the patch)
--- but only when debug_parallel_query was active. The reason
proved to be that we only bothered to mark Result nodes as potentially
parallel-safe when debug_parallel_query is on. This neglects the
fact that parallel-safety may be of interest for a sub-query even
though the Result itself doesn't parallelize.

There's only one existing test case that visibly changes plan with
these changes. The new plan is clearly saner-looking than before,
and testing with some data loaded into the table confirms that it
is faster. I'm not sure if it's worth devising more test cases.

I'll park this in the July commitfest.

regards, tom lane

[1] https://www.postgresql.org/message-id/flat/ZDVt6MaNWkRDO1LQ%40telsasoft.com

Attachment Content-Type Size
v1-allow-parallel-safe-initplans.patch text/x-diff 16.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2023-04-12 16:45:01 Re: [PATCH] Allow Postgres to pick an unused port to listen
Previous Message Jonathan S. Katz 2023-04-12 16:39:12 Re: longfin missing gssapi_ext.h