Re: partition routing layering in nodeModifyTable.c
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Amit Langote <amitlangote09@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>,
Daniel Gustafsson <daniel@yesql.se>, Etsuro Fujita
<etsuro.fujita@gmail.com>, Andres Freund <andres@anarazel.de>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-10-23T07:04:31Z
Lists: pgsql-hackers
On 22/10/2020 16:49, Amit Langote wrote: > On Tue, Oct 20, 2020 at 9:57 PM Amit Langote <amitlangote09@gmail.com> wrote: >> On Mon, Oct 19, 2020 at 8:55 PM Heikki Linnakangas <hlinnaka@iki.fi> wrote: >>> It's probably true that there's no performance gain from initializing >>> them more lazily. But the reasoning and logic around the initialization >>> is complicated. After tracing through various path through the code, I'm >>> convinced enough that it's correct, or at least these patches didn't >>> break it, but I still think some sort of lazy initialization on first >>> use would make it more readable. Or perhaps there's some other >>> refactoring we could do. >> >> So the other patch I have mentioned is about lazy initialization of >> the ResultRelInfo itself, not the individual fields, but maybe with >> enough refactoring we can get the latter too. > > So, I tried implementing a lazy-initialization-on-first-access > approach for both the ResultRelInfos themselves and some of the > individual fields of ResultRelInfo that don't need to be set right > away. You can see the end result in the attached 0003 patch. This > slims down ExecInitModifyTable() significantly, both in terms of code > footprint and the amount of work that it does. Have you done any performance testing? I'd like to know how much of a difference this makes in practice. Another alternative is to continue to create the ResultRelInfos in ExecInitModify(), but initialize the individual fields in them lazily. Does this patch become moot if we do the "Overhaul UPDATE/DELETE processing"? (https://www.postgresql.org/message-id/CA%2BHiwqHpHdqdDn48yCEhynnniahH78rwcrv1rEX65-fsZGBOLQ%40mail.gmail.com)? - Heikki
Commits
-
Fix initialization of es_result_relations in EvalPlanQualStart().
- 22b73d3cb0b5 14.0 landed
-
Remove PartitionRoutingInfo struct.
- fb5883da8615 14.0 landed
-
Revise child-to-root tuple conversion map management.
- 6973533650c0 14.0 landed
-
Clean up code to resolve the "root target relation" in nodeModifyTable.c
- f49b85d783f6 14.0 landed
-
Refactor code for cross-partition updates to a separate function.
- c5b097f8fa69 14.0 landed
-
Remove es_result_relation_info from EState.
- a04daa97a433 14.0 landed
-
Include result relation info in direct modify ForeignScan nodes.
- 178f2d560dde 14.0 landed
-
Create ResultRelInfos later in InitPlan, index them by RT index.
- 1375422c7826 14.0 landed