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

Commita67da49

Browse files
author
Amit Kapila
committed
Avoid duplicate table scans for cross-partition updates during logical replication.
When performing a cross-partition update in the apply worker, itneedlessly scans the old partition twice, resulting in noticeableoverhead.This commit optimizes it by removing the redundant table scan.Author: Hou ZhijieReviewed-by: Hayato Kuroda, Amit KapilaDiscussion:https://postgr.es/m/OS0PR01MB571623E39984D94CBB5341D994AB2@OS0PR01MB5716.jpnprd01.prod.outlook.com
1 parenta7f107d commita67da49

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

‎src/backend/replication/logical/worker.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,6 +2991,7 @@ apply_handle_tuple_routing(ApplyExecutionData *edata,
29912991
ResultRelInfo*partrelinfo_new;
29922992
Relationpartrel_new;
29932993
boolfound;
2994+
EPQStateepqstate;
29942995

29952996
/* Get the matching local tuple from the partition. */
29962997
found=FindReplTupleInLocalRel(edata,partrel,
@@ -3021,6 +3022,9 @@ apply_handle_tuple_routing(ApplyExecutionData *edata,
30213022
newtup);
30223023
MemoryContextSwitchTo(oldctx);
30233024

3025+
EvalPlanQualInit(&epqstate,estate,NULL,NIL,-1,NIL);
3026+
ExecOpenIndices(partrelinfo, false);
3027+
30243028
/*
30253029
* Does the updated tuple still satisfy the current
30263030
* partition's constraint?
@@ -3036,18 +3040,11 @@ apply_handle_tuple_routing(ApplyExecutionData *edata,
30363040
* work already done above to find the local tuple in the
30373041
* partition.
30383042
*/
3039-
EPQStateepqstate;
3040-
3041-
EvalPlanQualInit(&epqstate,estate,NULL,NIL,-1,NIL);
3042-
ExecOpenIndices(partrelinfo, false);
3043-
30443043
EvalPlanQualSetSlot(&epqstate,remoteslot_part);
30453044
TargetPrivilegesCheck(partrelinfo->ri_RelationDesc,
30463045
ACL_UPDATE);
30473046
ExecSimpleRelationUpdate(partrelinfo,estate,&epqstate,
30483047
localslot,remoteslot_part);
3049-
ExecCloseIndices(partrelinfo);
3050-
EvalPlanQualEnd(&epqstate);
30513048
}
30523049
else
30533050
{
@@ -3091,9 +3088,9 @@ apply_handle_tuple_routing(ApplyExecutionData *edata,
30913088
RelationGetRelationName(partrel_new));
30923089

30933090
/* DELETE old tuple found in the old partition. */
3094-
apply_handle_delete_internal(edata,partrelinfo,
3095-
localslot,
3096-
part_entry->localindexoid);
3091+
EvalPlanQualSetSlot(&epqstate,localslot);
3092+
TargetPrivilegesCheck(partrelinfo->ri_RelationDesc,ACL_DELETE);
3093+
ExecSimpleRelationDelete(partrelinfo,estate,&epqstate,localslot);
30973094

30983095
/* INSERT new tuple into the new partition. */
30993096

@@ -3123,6 +3120,9 @@ apply_handle_tuple_routing(ApplyExecutionData *edata,
31233120
apply_handle_insert_internal(edata,partrelinfo_new,
31243121
remoteslot_part);
31253122
}
3123+
3124+
ExecCloseIndices(partrelinfo);
3125+
EvalPlanQualEnd(&epqstate);
31263126
}
31273127
break;
31283128

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp