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

Commit2d32d90

Browse files
committed
Cleanup optimizer function names and clarify code.
1 parentaddddea commit2d32d90

File tree

17 files changed

+130
-112
lines changed

17 files changed

+130
-112
lines changed

‎src/backend/optimizer/README

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,36 @@ planner()
99
preprocess target list
1010
preprocess qualifications(WHERE)
1111
--query_planner()
12-
cnfify qualification, so qual are expressions (were AND's) and OR clauses
12+
cnfify()
13+
Summary:
14+
15+
Simple cases with all AND's are handled by removing the AND's:
16+
17+
convert: a = 1 AND b = 2 AND c = 3
18+
to: a = 1, b = 2, c = 3
19+
20+
Qualifications with OR's are handled differently. OR's inside AND
21+
clauses are not modified drastically:
22+
23+
convert: a = 1 AND b = 2 AND (c = 3 OR d = 4)
24+
to: a = 1, b = 2, c = 3 OR d = 4
25+
26+
OR's in the upper level are more complex to handle:
27+
28+
convert: (a = 1 AND b = 2) OR c = 3
29+
to: (a = 1 OR c = 3) AND (b = 2 OR c = 3)
30+
finally: (a = 1 OR c = 3), (b = 2 OR c = 3)
31+
32+
These clauses all have to be true for a result to be returned,
33+
so the optimizer can choose the most restrictive clauses.
34+
1335
pull out constants from target list
1436
get a target list that only contains column names, no expressions
1537
if none, then return
1638
---subplanner()
1739
make list of relations in target
1840
make list of relations in where clause
41+
split up the qual into restrictions (a=1) and joins (b=c)
1942
find which relations can do merge sort and hash joins
2043
----find_paths()
2144
find scan and all index paths for each relation not yet joined

‎src/backend/optimizer/geqo/geqo_eval.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: geqo_eval.c,v 1.21 1998/08/04 16:44:02 momjian Exp $
8+
* $Id: geqo_eval.c,v 1.22 1998/08/10 02:26:16 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -71,17 +71,17 @@ geqo_eval(Query *root, Gene *tour, int num_gene)
7171
List*temp;
7272

7373

74-
/* remember root->join_relation_list_ ... */
75-
/* because root->join_relation_list_ will be changed during the following */
76-
temp=listCopy(root->join_relation_list_);
74+
/* remember root->join_rel_list ... */
75+
/* because root->join_rel_list will be changed during the following */
76+
temp=listCopy(root->join_rel_list);
7777

7878
/* joinrel is readily processed query tree -- left-sided ! */
7979
joinrel=gimme_tree(root,tour,0,num_gene,NULL);
8080

8181
/* compute fitness */
8282
fitness= (Cost)joinrel->cheapestpath->path_cost;
8383

84-
root->join_relation_list_=listCopy(temp);
84+
root->join_rel_list=listCopy(temp);
8585

8686
pfree(joinrel);
8787
freeList(temp);
@@ -113,7 +113,7 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *out
113113
/* tour[0] = 3; tour[1] = 1; tour[2] = 2 */
114114
base_rel_index= (int)tour[rel_count];
115115

116-
inner_rel= (RelOptInfo*)geqo_nth(base_rel_index,root->base_relation_list_);
116+
inner_rel= (RelOptInfo*)geqo_nth(base_rel_index,root->base_rel_list);
117117

118118
if (rel_count==0)
119119
{/* processing first join with
@@ -169,7 +169,7 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *out
169169
new_rel->size=compute_rel_size(new_rel);
170170
new_rel->width=compute_rel_width(new_rel);
171171

172-
root->join_relation_list_=lcons(new_rel,NIL);
172+
root->join_rel_list=lcons(new_rel,NIL);
173173

174174
returngimme_tree(root,tour,rel_count,num_gene,new_rel);
175175
}
@@ -482,7 +482,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
482482
*/
483483

484484
/*
485-
* if ( (root->join_relation_list_) != NIL ) { rel =
485+
* if ( (root->join_rel_list) != NIL ) { rel =
486486
* get_join_rel(root, xrelid); } else { rel =
487487
* get_base_rel(root, lfirsti(xrelid)); }
488488
*/
@@ -495,7 +495,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
495495
*/
496496

497497
relids=lconsi(lfirsti(xrelid),NIL);
498-
rel=rel_member(relids,root->base_relation_list_);
498+
rel=rel_member(relids,root->base_rel_list);
499499

500500
add_superrels(rel,joinrel);
501501
}
@@ -521,7 +521,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
521521
*/
522522

523523
/*
524-
* if ( (root->join_relation_list_) != NIL ) { rel =
524+
* if ( (root->join_rel_list) != NIL ) { rel =
525525
* get_join_rel(root, xrelid); } else { rel =
526526
* get_base_rel(root, lfirsti(xrelid)); }
527527
*/
@@ -534,7 +534,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
534534
*/
535535

536536
relids=lconsi(lfirsti(xrelid),NIL);
537-
rel=rel_member(relids,root->base_relation_list_);
537+
rel=rel_member(relids,root->base_rel_list);
538538

539539
super_rels=rel->superrels;
540540
new_joininfo=makeNode(JInfo);

‎src/backend/optimizer/geqo/geqo_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: geqo_main.c,v 1.8 1998/07/18 04:22:27 momjian Exp $
9+
* $Id: geqo_main.c,v 1.9 1998/08/10 02:26:17 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -104,7 +104,7 @@ geqo(Query *root)
104104

105105

106106
/* set tour size */
107-
number_of_rels=length(root->base_relation_list_);
107+
number_of_rels=length(root->base_rel_list);
108108

109109
/* set GA parameters */
110110
geqo_params(number_of_rels);/* out of "$PGDATA/pg_geqo" file */

‎src/backend/optimizer/geqo/minspantree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Attic/minspantree.c,v 1.6 1998/07/18 04:22:29 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Attic/minspantree.c,v 1.7 1998/08/10 02:26:19 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -43,7 +43,7 @@
4343
void
4444
minspantree(Query*root,List*join_rels,RelOptInfo*garel)
4545
{
46-
intnumber_of_rels=length(root->base_relation_list_);
46+
intnumber_of_rels=length(root->base_rel_list);
4747
intnumber_of_joins=length(join_rels);
4848
int*connectto;
4949

‎src/backend/optimizer/path/allpaths.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.19 1998/08/07 05:02:15 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.20 1998/08/1002:26:20 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -45,7 +45,9 @@ int32_use_geqo_rels_ = GEQO_RELS;
4545

4646
staticvoidfind_rel_paths(Query*root,List*rels);
4747
staticList*find_join_paths(Query*root,List*outer_rels,intlevels_needed);
48+
#ifdefOPTIMIZER_DEBUG
4849
staticvoiddebug_print_rel(Query*root,RelOptInfo*rel);
50+
#endif
4951

5052
/*
5153
* find-paths--
@@ -74,15 +76,13 @@ find_paths(Query *root, List *rels)
7476

7577
if (levels_needed <=1)
7678
{
77-
7879
/*
7980
* Unsorted single relation, no more processing is required.
8081
*/
8182
returnrels;
8283
}
8384
else
8485
{
85-
8686
/*
8787
* this means that joins or sorts are required. set selectivities
8888
* of clauses that have not been set by an index.
@@ -115,8 +115,7 @@ find_rel_paths(Query *root, List *rels)
115115
List*or_index_scan_list;
116116
RelOptInfo*rel= (RelOptInfo*)lfirst(temp);
117117

118-
sequential_scan_list=lcons(create_seqscan_path(rel),
119-
NIL);
118+
sequential_scan_list=lcons(create_seqscan_path(rel),NIL);
120119

121120
rel_index_scan_list=
122121
find_index_paths(root,
@@ -181,7 +180,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
181180
* <utesch@aut.tu-freiberg.de> *
182181
*******************************************/
183182

184-
if ((_use_geqo_)&&length(root->base_relation_list_) >=_use_geqo_rels_)
183+
if ((_use_geqo_)&&length(root->base_rel_list) >=_use_geqo_rels_)
185184
returnlcons(geqo(root),NIL);/* returns *one* RelOptInfo, so lcons it */
186185

187186
/*******************************************
@@ -255,10 +254,10 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
255254
* merge join rels if then contain the same list of base rels
256255
*/
257256
outer_rels=merge_joinrels(new_rels,outer_rels);
258-
root->join_relation_list_=outer_rels;
257+
root->join_rel_list=outer_rels;
259258
}
260259
else
261-
root->join_relation_list_=new_rels;
260+
root->join_rel_list=new_rels;
262261
if (!BushyPlanFlag)
263262
outer_rels=new_rels;
264263
}

‎src/backend/optimizer/path/indxpath.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.25 1998/08/04 16:44:06 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.26 1998/08/10 02:26:22 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -662,7 +662,7 @@ match_clause_to_indexkey(RelOptInfo *rel,
662662
join_op= ((Oper*) ((Expr*)clause)->oper)->opno;
663663

664664
if (join_op&&op_class(join_op,xclass,index->relam)&&
665-
join_clause_p((Node*)clause))
665+
is_joinable((Node*)clause))
666666
{
667667
isIndexable= true;
668668

@@ -1153,7 +1153,7 @@ extract_restrict_clauses(List *clausegroup)
11531153
{
11541154
CInfo*cinfo=lfirst(l);
11551155

1156-
if (!join_clause_p((Node*)cinfo->clause))
1156+
if (!is_joinable((Node*)cinfo->clause))
11571157
restrict_cls=lappend(restrict_cls,cinfo);
11581158
}
11591159
returnrestrict_cls;
@@ -1282,7 +1282,7 @@ create_index_paths(Query *root,
12821282
foreach(j,clausegroup)
12831283
{
12841284
clauseinfo= (CInfo*)lfirst(j);
1285-
if (!(join_clause_p((Node*)clauseinfo->clause)&&
1285+
if (!(is_joinable((Node*)clauseinfo->clause)&&
12861286
equal_path_merge_ordering(index->ordering,
12871287
clauseinfo->mergejoinorder)))
12881288
temp= false;

‎src/backend/optimizer/path/joinrels.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.12 1998/08/04 16:44:08 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.13 1998/08/10 02:26:24 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -74,7 +74,7 @@ find_join_rels(Query *root, List *outer_rels)
7474
if (BushyPlanFlag)
7575
joins=find_clauseless_joins(outer_rel,outer_rels);
7676
else
77-
joins=find_clauseless_joins(outer_rel,root->base_relation_list_);
77+
joins=find_clauseless_joins(outer_rel,root->base_rel_list);
7878
}
7979

8080
join_list=nconc(join_list,joins);

‎src/backend/optimizer/path/xfunc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.17 1998/08/04 16:44:11 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.18 1998/08/10 02:26:25 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -734,7 +734,7 @@ xfunc_card_unreferenced(Query *queryInfo,
734734
LispValuetemp;
735735

736736
/* find all relids of base relations referenced in query */
737-
foreach(temp,queryInfo->base_relation_list_)
737+
foreach(temp,queryInfo->base_rel_list)
738738
{
739739
Assert(lnext(get_relids((RelOptInfo)lfirst(temp)))==LispNil);
740740
allrelids=lappend(allrelids,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp