aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-02-22 19:23:23 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2011-02-22 19:24:40 -0500
commitbdca82f44d0e0168dece56cbd53b54ba142f328f (patch)
tree0a627b98d399ddce7b4523cf1d138e721a860f9d /src/backend/optimizer
parent1c51c7d5ffd407426f314b2cd317ef77f14efb1f (diff)
downloadpostgresql-bdca82f44d0e0168dece56cbd53b54ba142f328f.tar.gz
postgresql-bdca82f44d0e0168dece56cbd53b54ba142f328f.zip
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.
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r--src/backend/optimizer/path/allpaths.c67
-rw-r--r--src/backend/optimizer/plan/planner.c3
2 files changed, 37 insertions, 33 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index c835a954ed9..dc2a23bb273 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -176,41 +176,44 @@ set_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
/* It's an "append relation", process accordingly */
set_append_rel_pathlist(root, rel, rti, rte);
}
- else if (rel->rtekind == RTE_SUBQUERY)
- {
- /* Subquery --- generate a separate plan for it */
- set_subquery_pathlist(root, rel, rti, rte);
- }
- else if (rel->rtekind == RTE_FUNCTION)
- {
- /* RangeFunction --- generate a suitable path for it */
- set_function_pathlist(root, rel, rte);
- }
- else if (rel->rtekind == RTE_VALUES)
- {
- /* Values list --- generate a suitable path for it */
- set_values_pathlist(root, rel, rte);
- }
- else if (rel->rtekind == RTE_CTE)
- {
- /* CTE reference --- generate a suitable path for it */
- if (rte->self_reference)
- set_worktable_pathlist(root, rel, rte);
- else
- set_cte_pathlist(root, rel, rte);
- }
else
{
- Assert(rel->rtekind == RTE_RELATION);
- if (get_rel_relkind(rte->relid) == RELKIND_FOREIGN_TABLE)
- {
- /* Foreign table */
- set_foreign_pathlist(root, rel, rte);
- }
- else
+ switch (rel->rtekind)
{
- /* Plain relation */
- set_plain_rel_pathlist(root, rel, rte);
+ case RTE_RELATION:
+ if (rte->relkind == RELKIND_FOREIGN_TABLE)
+ {
+ /* Foreign table */
+ set_foreign_pathlist(root, rel, rte);
+ }
+ else
+ {
+ /* Plain relation */
+ set_plain_rel_pathlist(root, rel, rte);
+ }
+ break;
+ case RTE_SUBQUERY:
+ /* Subquery --- generate a separate plan for it */
+ set_subquery_pathlist(root, rel, rti, rte);
+ break;
+ case RTE_FUNCTION:
+ /* RangeFunction --- generate a suitable path for it */
+ set_function_pathlist(root, rel, rte);
+ break;
+ case RTE_VALUES:
+ /* Values list --- generate a suitable path for it */
+ set_values_pathlist(root, rel, rte);
+ break;
+ case RTE_CTE:
+ /* CTE reference --- generate a suitable path for it */
+ if (rte->self_reference)
+ set_worktable_pathlist(root, rel, rte);
+ else
+ set_cte_pathlist(root, rel, rte);
+ break;
+ default:
+ elog(ERROR, "unexpected rtekind: %d", (int) rel->rtekind);
+ break;
}
}
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index b73b872b312..ee09673051f 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -1915,7 +1915,7 @@ preprocess_rowmarks(PlannerInfo *root)
newrc->rowmarkId = ++(root->glob->lastRowMarkId);
/* real tables support REFERENCE, anything else needs COPY */
if (rte->rtekind == RTE_RELATION &&
- get_rel_relkind(rte->relid) != RELKIND_FOREIGN_TABLE)
+ rte->relkind != RELKIND_FOREIGN_TABLE)
newrc->markType = ROW_MARK_REFERENCE;
else
newrc->markType = ROW_MARK_COPY;
@@ -3078,6 +3078,7 @@ plan_cluster_use_sort(Oid tableOid, Oid indexOid)
rte = makeNode(RangeTblEntry);
rte->rtekind = RTE_RELATION;
rte->relid = tableOid;
+ rte->relkind = RELKIND_RELATION;
rte->inh = false;
rte->inFromCl = true;
query->rtable = list_make1(rte);