Skip to content

Commit dca48d1

Browse files
committed
Remove useless lookup of root partitioned rel in ExecInitModifyTable().
node->partitioned_rels is only set in UPDATE/DELETE cases, but ExecInitModifyTable only uses its "rel" variable in INSERT cases, so the extra logic to find the root rel is just a waste of complexity and cycles. Etsuro Fujita, reviewed by Amit Langote Discussion: https://postgr.es/m/93cf9816-2f7d-0f67-8ed2-4a4e497a6ab8@lab.ntt.co.jp
1 parent 9c7d06d commit dca48d1

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

src/backend/executor/nodeModifyTable.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#include "foreign/fdwapi.h"
4747
#include "miscadmin.h"
4848
#include "nodes/nodeFuncs.h"
49-
#include "parser/parsetree.h"
5049
#include "storage/bufmgr.h"
5150
#include "storage/lmgr.h"
5251
#include "utils/builtins.h"
@@ -1932,20 +1931,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
19321931

19331932
estate->es_result_relation_info = saved_resultRelInfo;
19341933

1935-
/* The root table RT index is at the head of the partitioned_rels list */
1936-
if (node->partitioned_rels)
1937-
{
1938-
Index root_rti;
1939-
Oid root_oid;
1940-
1941-
root_rti = linitial_int(node->partitioned_rels);
1942-
root_oid = getrelid(root_rti, estate->es_range_table);
1943-
rel = heap_open(root_oid, NoLock); /* locked by InitPlan */
1944-
}
1945-
else
1946-
rel = mtstate->resultRelInfo->ri_RelationDesc;
1947-
19481934
/* Build state for INSERT tuple routing */
1935+
rel = mtstate->resultRelInfo->ri_RelationDesc;
19491936
if (operation == CMD_INSERT &&
19501937
rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
19511938
{
@@ -2118,10 +2105,6 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
21182105
mtstate->ps.ps_ExprContext = NULL;
21192106
}
21202107

2121-
/* Close the root partitioned rel if we opened it above. */
2122-
if (rel != mtstate->resultRelInfo->ri_RelationDesc)
2123-
heap_close(rel, NoLock);
2124-
21252108
/*
21262109
* If needed, Initialize target list, projection and qual for ON CONFLICT
21272110
* DO UPDATE.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy