mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +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:
@ -1927,6 +1927,7 @@ _copyRangeTblEntry(RangeTblEntry *from)
|
||||
|
||||
COPY_SCALAR_FIELD(rtekind);
|
||||
COPY_SCALAR_FIELD(relid);
|
||||
COPY_SCALAR_FIELD(relkind);
|
||||
COPY_NODE_FIELD(subquery);
|
||||
COPY_SCALAR_FIELD(jointype);
|
||||
COPY_NODE_FIELD(joinaliasvars);
|
||||
|
@ -2286,6 +2286,7 @@ _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
|
||||
{
|
||||
COMPARE_SCALAR_FIELD(rtekind);
|
||||
COMPARE_SCALAR_FIELD(relid);
|
||||
COMPARE_SCALAR_FIELD(relkind);
|
||||
COMPARE_NODE_FIELD(subquery);
|
||||
COMPARE_SCALAR_FIELD(jointype);
|
||||
COMPARE_NODE_FIELD(joinaliasvars);
|
||||
|
@ -1671,7 +1671,6 @@ range_table_walker(List *rtable,
|
||||
switch (rte->rtekind)
|
||||
{
|
||||
case RTE_RELATION:
|
||||
case RTE_SPECIAL:
|
||||
case RTE_CTE:
|
||||
/* nothing to do */
|
||||
break;
|
||||
@ -2374,7 +2373,6 @@ range_table_mutator(List *rtable,
|
||||
switch (rte->rtekind)
|
||||
{
|
||||
case RTE_RELATION:
|
||||
case RTE_SPECIAL:
|
||||
case RTE_CTE:
|
||||
/* we don't bother to copy eref, aliases, etc; OK? */
|
||||
break;
|
||||
|
@ -2275,8 +2275,8 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
|
||||
switch (node->rtekind)
|
||||
{
|
||||
case RTE_RELATION:
|
||||
case RTE_SPECIAL:
|
||||
WRITE_OID_FIELD(relid);
|
||||
WRITE_CHAR_FIELD(relkind);
|
||||
break;
|
||||
case RTE_SUBQUERY:
|
||||
WRITE_NODE_FIELD(subquery);
|
||||
|
@ -265,8 +265,8 @@ print_rt(List *rtable)
|
||||
switch (rte->rtekind)
|
||||
{
|
||||
case RTE_RELATION:
|
||||
printf("%d\t%s\t%u",
|
||||
i, rte->eref->aliasname, rte->relid);
|
||||
printf("%d\t%s\t%u\t%c",
|
||||
i, rte->eref->aliasname, rte->relid, rte->relkind);
|
||||
break;
|
||||
case RTE_SUBQUERY:
|
||||
printf("%d\t%s\t[subquery]",
|
||||
@ -276,10 +276,6 @@ print_rt(List *rtable)
|
||||
printf("%d\t%s\t[join]",
|
||||
i, rte->eref->aliasname);
|
||||
break;
|
||||
case RTE_SPECIAL:
|
||||
printf("%d\t%s\t[special]",
|
||||
i, rte->eref->aliasname);
|
||||
break;
|
||||
case RTE_FUNCTION:
|
||||
printf("%d\t%s\t[rangefunction]",
|
||||
i, rte->eref->aliasname);
|
||||
|
@ -1171,8 +1171,8 @@ _readRangeTblEntry(void)
|
||||
switch (local_node->rtekind)
|
||||
{
|
||||
case RTE_RELATION:
|
||||
case RTE_SPECIAL:
|
||||
READ_OID_FIELD(relid);
|
||||
READ_CHAR_FIELD(relkind);
|
||||
break;
|
||||
case RTE_SUBQUERY:
|
||||
READ_NODE_FIELD(subquery);
|
||||
|
Reference in New Issue
Block a user