Re: parallelize queries containing initplans
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Haribabu Kommi <kommi.haribabu@gmail.com>, Kuntal Ghosh <kuntalghosh.2007@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2017-11-10T18:45:25Z
Lists: pgsql-hackers
Attachments
- 0001-param-exec-types-v1.patch (application/octet-stream) patch v1-0001
- 0002-pq-pushdown-initplan-rebased.patch (application/octet-stream) patch 0002
On Tue, Nov 7, 2017 at 4:45 AM, Amit Kapila <amit.kapila16@gmail.com> wrote: > As mentioned, changed the status of the patch in CF app. I spent some time reviewing this patch today and found myself still quite uncomfortable with the fact that it was adding execution-time work to track the types of parameters - types that would usually not even be used. I found the changes to nodeNestLoop.c to be particularly objectionable, because we could end up doing the work over and over when it is actually not needed at all, or at most once. I decided to try instead teaching the planner to keep track of the types of PARAM_EXEC parameters as they were created, and that seems to work fine. See 0001, attached. 0002, attached, is my worked-over version of the rest of the patch. I moved the code that serializes and deserializes PARAM_EXEC from nodeSubplan.c -- which seemed like a strange choice - to execParallel.c. I removed the type OID from the serialization format because there's no reason to do that any more; the worker already knows the types from the plan. I did some renaming of the functions involved and some adjustment of the comments to refer to "PARAM_EXEC parameters" instead of initPlan parameters, because there's no reason that I can see why this can only work for initPlans. A Gather node on the inner side of a nested loop doesn't sound like a great idea, but I think this infrastructure could handle it (though it would need some more planner work). I broke a lot of long lines in your version of the patch into multiple lines; please try to be attentive to this issue when writing patches in general, as it is a bit tedious to go through and insert line breaks in many places. Please let me know your thoughts on the attached patches. Thanks, -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Commits
-
Pass InitPlan values to workers via Gather (Merge).
- e89a71fb449a 11.0 landed
-
Track in the plan the types associated with PARAM_EXEC parameters.
- e64861c79bda 11.0 landed
-
Force rescanning of parallel-aware scan nodes below a Gather[Merge].
- 7df2c1f8daeb 11.0 cited