postgresql/src/backend
Alvaro Herrera 3f2393edef Redesign initialization of partition routing structures
This speeds up write operations (INSERT, UPDATE, DELETE, COPY, as well
as the future MERGE) on partitioned tables.

This changes the setup for tuple routing so that it does far less work
during the initial setup and pushes more work out to when partitions
receive tuples.  PartitionDispatchData structs for sub-partitioned
tables are only created when a tuple gets routed through it.  The
possibly large arrays in the PartitionTupleRouting struct have largely
been removed.  The partitions[] array remains but now never contains any
NULL gaps.  Previously the NULLs had to be skipped during
ExecCleanupTupleRouting(), which could add a large overhead to the
cleanup when the number of partitions was large.  The partitions[] array
is allocated small to start with and only enlarged when we route tuples
to enough partitions that it runs out of space. This allows us to keep
simple single-row partition INSERTs running quickly.  Redesign

The arrays in PartitionTupleRouting which stored the tuple translation maps
have now been removed.  These have been moved out into a
PartitionRoutingInfo struct which is an additional field in ResultRelInfo.

The find_all_inheritors() call still remains by far the slowest part of
ExecSetupPartitionTupleRouting(). This commit just removes the other slow
parts.

In passing also rename the tuple translation maps from being ParentToChild
and ChildToParent to being RootToPartition and PartitionToRoot. The old
names mislead you into thinking that a partition of some sub-partitioned
table would translate to the rowtype of the sub-partitioned table rather
than the root partitioned table.

Authors: David Rowley and Amit Langote, heavily revised by Álvaro Herrera
Testing help from Jesper Pedersen and Kato Sho.
Discussion: https://postgr.es/m/CAKJS1f_1RJyFquuCKRFHTdcXqoPX-PYqAd7nz=GVBwvGh4a6xA@mail.gmail.com
2018-11-16 15:01:05 -03:00
..
access Introduce notion of different types of slots (without implementing them). 2018-11-15 22:00:30 -08:00
bootstrap Install a check for mis-linking of src/port and src/common functions. 2018-09-09 12:23:23 -04:00
catalog Introduce notion of different types of slots (without implementing them). 2018-11-15 22:00:30 -08:00
commands Redesign initialization of partition routing structures 2018-11-16 15:01:05 -03:00
executor Redesign initialization of partition routing structures 2018-11-16 15:01:05 -03:00
foreign Correct constness of a few variables. 2018-10-15 21:01:14 -07:00
jit Don't generate tuple deforming functions for virtual slots. 2018-11-15 22:00:30 -08:00
lib Rename rbtree.c functions to use "rbt" prefix not "rb" prefix. 2018-11-06 13:25:24 -05:00
libpq Fix const correctness warning. 2018-11-13 19:03:02 +13:00
main Update copyright for 2018 2018-01-02 23:30:12 -05:00
nodes Revise attribute handling code on partition creation 2018-11-08 16:22:09 -03:00
optimizer Redesign initialization of partition routing structures 2018-11-16 15:01:05 -03:00
parser Fix realfailN lexer rules to not make assumptions about input format. 2018-11-13 14:54:41 -05:00
partitioning Introduce notion of different types of slots (without implementing them). 2018-11-15 22:00:30 -08:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Fix spelling errors and typos in comments 2018-11-02 13:56:52 +01:00
postmaster Further adjustment to random() seed initialization. 2018-11-15 17:38:55 +13:00
regex Clean up warnings from -Wimplicit-fallthrough. 2018-05-01 19:35:08 -04:00
replication Introduce notion of different types of slots (without implementing them). 2018-11-15 22:00:30 -08:00
rewrite Change rewriter/planner/executor/plancache to depend on RTE rellockmode. 2018-10-02 14:43:09 -04:00
snowball Sync our Snowball stemmer dictionaries with current upstream. 2018-09-24 17:29:38 -04:00
statistics Fix typos. 2018-08-27 09:32:59 +12:00
storage Use 64 bit type for BufFileSize(). 2018-11-15 13:13:57 +13:00
tcop Introduce notion of different types of slots (without implementing them). 2018-11-15 22:00:30 -08:00
tsearch Make ts_locale.c's character-type functions cope with UTF-16. 2018-11-03 13:56:10 -04:00
utils Redesign initialization of partition routing structures 2018-11-16 15:01:05 -03:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Refactor dlopen() support 2018-09-06 11:33:04 +02:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00