Re: ATTACH/DETACH PARTITION CONCURRENTLY
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Robert Haas <robertmhaas@gmail.com>, David Rowley <david.rowley@2ndquadrant.com>, Alvaro Herrera <alvherre@2ndquadrant.com>, Andres Freund <andres@anarazel.de>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Simon Riggs <simon@2ndquadrant.com>
Date: 2018-11-15T06:22:04Z
Lists: pgsql-hackers
On Thu, Nov 15, 2018 at 02:53:47PM +0900, Amit Langote wrote: > As things stand today, rd_partdesc of a partitioned table must always be > non-NULL. In fact, there are many places in the backend code that Assert it: > > [...] I have noticed those, and they actually would not care much if rd_partdesc was actually NULL. I find interesting that the planner portion actually does roughly the same thing with a partitioned table with no partitions and a non-partitioned table. > Maybe there are others in a different form. > > If there are no partitions, nparts is 0, and other fields are NULL, though > rd_partdesc itself is never NULL. I find a bit confusing that both concepts have the same meaning, aka that a relation has no partition, and that it is actually relkind which decides rd_partdesc should be NULL or set up. This stuff also does empty allocations. > If we want to redesign that and allow it to be NULL until some code in the > backend wants to use it, then maybe we can consider doing what you say. > But, many non-trivial operations on partitioned tables require the > PartitionDesc, so there is perhaps not much point to designing it such > that rd_partdesc is set only when needed, because it will be referenced > sooner than later. Maybe, we can consider doing that sort of thing for > boundinfo, because it's expensive to build, and not all operations want > the canonicalized bounds. I am fine if that's the consensus of this thread. But as far as I can see it is possible to remove a bit of the memory handling mess by doing so. My 2c. -- Michael
Commits
-
Allow ATTACH PARTITION with only ShareUpdateExclusiveLock.
- 898e5e3290a7 12.0 landed
-
Change lock acquisition order in expand_inherited_rtentry.
- f4b6341d5fcb 12.0 landed
-
Move code for managing PartitionDescs into a new file, partdesc.c
- 1bb5e7821810 12.0 landed
-
Remove more redundant relation locking during executor startup.
- f2343653f5b2 12.0 cited
-
Add assertions that we hold some relevant lock during relation open.
- b04aeb0a053e 12.0 cited
-
Try to acquire relation locks in RangeVarGetRelid.
- 4240e429d0c2 9.2.0 cited