Re: moving extraUpdatedCols out of RangeTblEntry (into ModifyTable)
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Langote <amitlangote09@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: 2023-01-04T19:59:11Z
Lists: pgsql-hackers
Attachments
- compute-extraUpdatedCols-at-runtime-1.patch (text/x-diff) patch
I wrote: > After further thought: maybe we should get radical and postpone this > work all the way to executor startup. The downside of that is having > to do it over again on each execution of a prepared plan. But the > upside is that when the UPDATE targets a many-partitioned table, > we would have a chance at not doing the work at all for partitions > that get pruned at runtime. I'm not sure if that win would emerge > immediately or if we still have executor work to do to manage pruning > of the target table. I'm also not sure that this'd be a net win > overall. But it seems worth considering. Here's a draft patch that does it like that. This seems like a win for more reasons than just pruning, because I was able to integrate the calculation into runtime setup of the expressions, so that we aren't doing an extra stringToNode() on them. There's still a code path that does such a calculation at plan time (get_rel_all_updated_cols), but it's only used by postgres_fdw which has some other rather-inefficient behaviors in the same area. I've not looked into what it'd take to back-patch this. We can't add a field to ResultRelInfo in released branches (cf 4b3e37993), but we might be able to repurpose RangeTblEntry.extraUpdatedCols. regards, tom lane
Commits
-
Fix calculation of which GENERATED columns need to be updated.
- ad38e2f89116 13.10 landed
- 8cd190e13a22 14.7 landed
- 3f7836ff651a 16.0 landed
- 3706cc97aa36 15.2 landed
-
Push lpp variable closer to usage in heapgetpage()
- e351f8541831 16.0 cited