From afcf09dd9034f24e34dd46f69938882ab5b103d2 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 21 Apr 2007 21:01:45 +0000 Subject: Some further performance tweaks for planning large inheritance trees that are mostly excluded by constraints: do the CE test a bit earlier to save some adjust_appendrel_attrs() work on excluded children, and arrange to use array indexing rather than rt_fetch() to fetch RTEs in the main body of the planner. The latter is something I'd wanted to do for awhile anyway, but seeing list_nth_cell() as 35% of the runtime gets one's attention. --- src/backend/optimizer/util/relnode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/backend/optimizer/util/relnode.c') diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c index 6dfd2f61149..56f8f3493c2 100644 --- a/src/backend/optimizer/util/relnode.c +++ b/src/backend/optimizer/util/relnode.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.86 2007/02/22 22:00:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.87 2007/04/21 21:01:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -56,15 +56,15 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptKind reloptkind) RelOptInfo *rel; RangeTblEntry *rte; - /* Fetch RTE for relation */ - Assert(relid > 0 && relid <= list_length(root->parse->rtable)); - rte = rt_fetch(relid, root->parse->rtable); - /* Rel should not exist already */ - Assert(relid < root->simple_rel_array_size); + Assert(relid > 0 && relid < root->simple_rel_array_size); if (root->simple_rel_array[relid] != NULL) elog(ERROR, "rel %d already exists", relid); + /* Fetch RTE for relation */ + rte = root->simple_rte_array[relid]; + Assert(rte != NULL); + rel = makeNode(RelOptInfo); rel->reloptkind = reloptkind; rel->relids = bms_make_singleton(relid); -- cgit v1.2.3