aboutsummaryrefslogtreecommitdiff
path: root/src/include/executor/execPartition.h
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2018-02-22 10:55:54 -0500
committerRobert Haas <rhaas@postgresql.org>2018-02-22 10:55:54 -0500
commitedd44738bc88148784899a8949519364d81d9ea8 (patch)
tree6f24444cc5f016d1e2ec6d8bb6c4f9476cb9b00a /src/include/executor/execPartition.h
parent810e7e264ab547c404e32dba4f8733db53912084 (diff)
downloadpostgresql-edd44738bc88148784899a8949519364d81d9ea8.tar.gz
postgresql-edd44738bc88148784899a8949519364d81d9ea8.zip
Be lazier about partition tuple routing.
It's not necessary to fully initialize the executor data structures for partitions to which no tuples are ever routed. Consider, for example, an INSERT statement that inserts only one row: it only cares about the partition to which that one row is routed. The new function ExecInitPartitionInfo performs the initialization in question only when a particular partition is about to receive a tuple. This includes creating, validating, and saving a pointer to the ResultRelInfo, setting up for speculative insertions, translating WCOs and initializing the resulting expressions, translating returning lists and building the appropriate projection information, and setting up a tuple conversion map. One thing that's not deferred is locking the child partitions; that seems desirable but would need more thought. Still, testing shows that this makes single-row inserts significantly faster on a table with many partitions without harming the bulk-insert case. Amit Langote, reviewed by Etsuro Fujita, with a few changes by me Discussion: http://postgr.es/m/8975331d-d961-cbdd-f862-fdd3d97dc2d0@lab.ntt.co.jp
Diffstat (limited to 'src/include/executor/execPartition.h')
-rw-r--r--src/include/executor/execPartition.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/include/executor/execPartition.h b/src/include/executor/execPartition.h
index 3df9c498bbf..e94718608fb 100644
--- a/src/include/executor/execPartition.h
+++ b/src/include/executor/execPartition.h
@@ -58,6 +58,7 @@ typedef struct PartitionDispatchData *PartitionDispatch;
* partition tree.
* num_dispatch number of partitioned tables in the partition
* tree (= length of partition_dispatch_info[])
+ * partition_oids Array of leaf partitions OIDs
* partitions Array of ResultRelInfo* objects with one entry
* for every leaf partition in the partition tree.
* num_partitions Number of leaf partitions in the partition tree
@@ -91,6 +92,7 @@ typedef struct PartitionTupleRouting
{
PartitionDispatch *partition_dispatch_info;
int num_dispatch;
+ Oid *partition_oids;
ResultRelInfo **partitions;
int num_partitions;
TupleConversionMap **parent_child_tupconv_maps;
@@ -103,12 +105,15 @@ typedef struct PartitionTupleRouting
} PartitionTupleRouting;
extern PartitionTupleRouting *ExecSetupPartitionTupleRouting(ModifyTableState *mtstate,
- Relation rel, Index resultRTindex,
- EState *estate);
+ Relation rel);
extern int ExecFindPartition(ResultRelInfo *resultRelInfo,
PartitionDispatch *pd,
TupleTableSlot *slot,
EState *estate);
+extern ResultRelInfo *ExecInitPartitionInfo(ModifyTableState *mtstate,
+ ResultRelInfo *resultRelInfo,
+ PartitionTupleRouting *proute,
+ EState *estate, int partidx);
extern void ExecSetupChildParentMapForLeaf(PartitionTupleRouting *proute);
extern TupleConversionMap *TupConvMapForLeaf(PartitionTupleRouting *proute,
ResultRelInfo *rootRelInfo, int leaf_index);