1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Add a relkind field to RangeTblEntry to avoid some syscache lookups.

The recent additions for FDW support required checking foreign-table-ness
in several places in the parse/plan chain.  While it's not clear whether
that would really result in a noticeable slowdown, it seems best to avoid
any performance risk by keeping a copy of the relation's relkind in
RangeTblEntry.  That might have some other uses later, anyway.
Per discussion.
This commit is contained in:
Tom Lane
2011-02-22 19:23:23 -05:00
parent 1c51c7d5ff
commit bdca82f44d
19 changed files with 85 additions and 74 deletions

View File

@ -144,6 +144,13 @@ AcquireRewriteLocks(Query *parsetree, bool forUpdatePushedDown)
lockmode = AccessShareLock;
rel = heap_open(rte->relid, lockmode);
/*
* While we have the relation open, update the RTE's relkind,
* just in case it changed since this rule was made.
*/
rte->relkind = rel->rd_rel->relkind;
heap_close(rel, NoLock);
break;
@ -1393,7 +1400,7 @@ markQueryForLocking(Query *qry, Node *jtnode,
if (rte->rtekind == RTE_RELATION)
{
/* ignore foreign tables */
if (get_rel_relkind(rte->relid) != RELKIND_FOREIGN_TABLE)
if (rte->relkind != RELKIND_FOREIGN_TABLE)
{
applyLockingClause(qry, rti, forUpdate, noWait, pushedDown);
rte->requiredPerms |= ACL_SELECT_FOR_UPDATE;