Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38db5fa

Browse files
committed
Make inheritance planning logic a little simpler and clearer,
hopefully even a little faster.
1 parent996659f commit38db5fa

File tree

4 files changed

+145
-116
lines changed

4 files changed

+145
-116
lines changed

‎src/backend/optimizer/plan/planner.c

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.84 2000/06/1822:44:09 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.85 2000/06/20 04:22:21 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -94,7 +94,8 @@ planner(Query *parse)
9494
* Basically, this routine does the stuff that should only be done once
9595
* per Query object. It then calls union_planner, which may be called
9696
* recursively on the same Query node in order to handle UNIONs and/or
97-
* inheritance. subquery_planner is called recursively from subselect.c.
97+
* inheritance. subquery_planner is called recursively from subselect.c
98+
* to handle sub-Query nodes found within the query's expressions.
9899
*
99100
* prepunion.c uses an unholy combination of calling union_planner when
100101
* recursing on the primary Query node, or subquery_planner when recursing
@@ -107,10 +108,6 @@ planner(Query *parse)
107108
Plan*
108109
subquery_planner(Query*parse,doubletuple_fraction)
109110
{
110-
List*l;
111-
List*rangetable=parse->rtable;
112-
RangeTblEntry*rangeTblEntry;
113-
114111
/*
115112
* A HAVING clause without aggregates is equivalent to a WHERE clause
116113
* (except it can only refer to grouped fields). If there are no aggs
@@ -142,18 +139,6 @@ subquery_planner(Query *parse, double tuple_fraction)
142139
parse->qual=eval_const_expressions(parse->qual);
143140
parse->havingQual=eval_const_expressions(parse->havingQual);
144141

145-
/*
146-
* If the query is going to look for subclasses, but no subclasses
147-
* actually exist, then we can optimise away the union that would
148-
* otherwise happen and thus save some time.
149-
*/
150-
foreach(l,rangetable)
151-
{
152-
rangeTblEntry= (RangeTblEntry*)lfirst(l);
153-
if (rangeTblEntry->inh&& !has_subclass(rangeTblEntry->relid))
154-
rangeTblEntry->inh= FALSE;
155-
}
156-
157142
/*
158143
* Canonicalize the qual, and convert it to implicit-AND format.
159144
*
@@ -257,10 +242,11 @@ union_planner(Query *parse,
257242
List*group_pathkeys;
258243
List*sort_pathkeys;
259244
Indexrt_index;
245+
List*inheritors;
260246

261247
if (parse->unionClause)
262248
{
263-
result_plan=(Plan*)plan_union_queries(parse);
249+
result_plan=plan_union_queries(parse);
264250
/* XXX do we need to do this? bjm 12/19/97 */
265251
tlist=preprocess_targetlist(tlist,
266252
parse->commandType,
@@ -269,9 +255,8 @@ union_planner(Query *parse,
269255

270256
/*
271257
* We leave current_pathkeys NIL indicating we do not know sort
272-
* order. Actually, for a normal UNION we have done an explicit
273-
* sort; ought to change interface to plan_union_queries to pass
274-
* that info back!
258+
* order. This is correct for the appended-together subplan
259+
* results, even if the subplans themselves produced sorted results.
275260
*/
276261

277262
/*
@@ -283,7 +268,8 @@ union_planner(Query *parse,
283268
sort_pathkeys=make_pathkeys_for_sortclauses(parse->sortClause,
284269
tlist);
285270
}
286-
elseif ((rt_index=first_inherit_rt_entry(rangetable))!=-1)
271+
elseif (find_inheritable_rt_entry(rangetable,
272+
&rt_index,&inheritors))
287273
{
288274
List*sub_tlist;
289275

@@ -296,8 +282,8 @@ union_planner(Query *parse,
296282
/*
297283
* Recursively plan the subqueries needed for inheritance
298284
*/
299-
result_plan=(Plan*)plan_inherit_queries(parse,sub_tlist,
300-
rt_index);
285+
result_plan=plan_inherit_queries(parse,sub_tlist,
286+
rt_index,inheritors);
301287

302288
/*
303289
* Fix up outer target list. NOTE: unlike the case for

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp