Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitedd4473

Browse files
committed
Be lazier about partition tuple routing.
It's not necessary to fully initialize the executor data structuresfor partitions to which no tuples are ever routed. Consider, forexample, an INSERT statement that inserts only one row: it only caresabout the partition to which that one row is routed. The new functionExecInitPartitionInfo performs the initialization in question onlywhen a particular partition is about to receive a tuple. This includescreating, validating, and saving a pointer to the ResultRelInfo,setting up for speculative insertions, translating WCOs andinitializing the resulting expressions, translating returning listsand building the appropriate projection information, and setting up atuple conversion map.One thing that's not deferred is locking the child partitions; thatseems desirable but would need more thought. Still, testing showsthat this makes single-row inserts significantly faster on a tablewith many partitions without harming the bulk-insert case.Amit Langote, reviewed by Etsuro Fujita, with a few changes by meDiscussion:http://postgr.es/m/8975331d-d961-cbdd-f862-fdd3d97dc2d0@lab.ntt.co.jp
1 parent810e7e2 commitedd4473

File tree

4 files changed

+279
-232
lines changed

4 files changed

+279
-232
lines changed

‎src/backend/commands/copy.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2469,7 +2469,7 @@ CopyFrom(CopyState cstate)
24692469
PartitionTupleRouting*proute;
24702470

24712471
proute=cstate->partition_tuple_routing=
2472-
ExecSetupPartitionTupleRouting(NULL,cstate->rel,1,estate);
2472+
ExecSetupPartitionTupleRouting(NULL,cstate->rel);
24732473

24742474
/*
24752475
* If we are capturing transition tuples, they may need to be
@@ -2606,6 +2606,14 @@ CopyFrom(CopyState cstate)
26062606
*/
26072607
saved_resultRelInfo=resultRelInfo;
26082608
resultRelInfo=proute->partitions[leaf_part_index];
2609+
if (resultRelInfo==NULL)
2610+
{
2611+
resultRelInfo=ExecInitPartitionInfo(NULL,
2612+
saved_resultRelInfo,
2613+
proute,estate,
2614+
leaf_part_index);
2615+
Assert(resultRelInfo!=NULL);
2616+
}
26092617

26102618
/* We do not yet have a way to insert into a foreign partition */
26112619
if (resultRelInfo->ri_FdwRoutine)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp