Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
d977ff7b
Commit
d977ff7b
authored
Feb 18, 1999
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more optimizer cleanups
parent
63393bdf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
54 deletions
+40
-54
src/backend/optimizer/path/joinrels.c
src/backend/optimizer/path/joinrels.c
+35
-49
src/include/optimizer/paths.h
src/include/optimizer/paths.h
+5
-5
No files found.
src/backend/optimizer/path/joinrels.c
View file @
d977ff7b
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.2
7 1999/02/18 00:49:20
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.2
8 1999/02/18 04:45:36
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -46,37 +46,35 @@ static void set_joinrel_size(RelOptInfo *joinrel, RelOptInfo *outer_rel,
* of these exist for a given relation, all remaining possibilities are
* considered.
*
* 'outer_rels' is the list of rel nodes
*
* Returns a list of rel nodes corresponding to the new join relations.
*/
List
*
make_rels_by_joins
(
Query
*
root
,
List
*
o
uter
_rels
)
make_rels_by_joins
(
Query
*
root
,
List
*
o
ld
_rels
)
{
List
*
joins
=
NIL
;
List
*
join
ed_rel
s
=
NIL
;
List
*
join_list
=
NIL
;
List
*
r
=
NIL
;
foreach
(
r
,
o
uter
_rels
)
foreach
(
r
,
o
ld
_rels
)
{
RelOptInfo
*
o
uter
_rel
=
(
RelOptInfo
*
)
lfirst
(
r
);
RelOptInfo
*
o
ld
_rel
=
(
RelOptInfo
*
)
lfirst
(
r
);
if
(
!
(
join
s
=
make_rels_by_clause_joins
(
root
,
outer
_rel
,
o
uter
_rel
->
joininfo
,
if
(
!
(
join
ed_rels
=
make_rels_by_clause_joins
(
root
,
old
_rel
,
o
ld
_rel
->
joininfo
,
NIL
)))
{
/*
* Oops, we have a relation that is not joined to any other
* relation. Cartesian product time.
*/
if
(
!
BushyPlanFlag
)
joins
=
make_rels_by_clauseless_joins
(
outer_rel
,
root
->
base_rel_list
);
else
joins
=
make_rels_by_clauseless_joins
(
outer_rel
,
outer
_rels
);
joined_rels
=
make_rels_by_clauseless_joins
(
old_rel
,
root
->
base_rel_list
);
if
(
BushyPlanFlag
)
joined_rels
=
make_rels_by_clauseless_joins
(
old_rel
,
old
_rels
);
}
join_list
=
nconc
(
join_list
,
joins
);
join_list
=
nconc
(
join_list
,
join
ed_rel
s
);
}
return
join_list
;
...
...
@@ -98,7 +96,7 @@ make_rels_by_joins(Query *root, List *outer_rels)
* Returns a list of new join relations.
*/
List
*
make_rels_by_clause_joins
(
Query
*
root
,
RelOptInfo
*
o
uter
_rel
,
make_rels_by_clause_joins
(
Query
*
root
,
RelOptInfo
*
o
ld
_rel
,
List
*
joininfo_list
,
Relids
only_relids
)
{
List
*
join_list
=
NIL
;
...
...
@@ -107,7 +105,7 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel,
foreach
(
i
,
joininfo_list
)
{
JoinInfo
*
joininfo
=
(
JoinInfo
*
)
lfirst
(
i
);
RelOptInfo
*
rel
;
RelOptInfo
*
joined_
rel
;
Relids
unjoined_relids
=
joininfo
->
unjoined_relids
;
if
(
unjoined_relids
!=
NIL
)
...
...
@@ -117,20 +115,21 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel,
/* geqo only wants certain relids to make new rels */
intMember
(
lfirsti
(
unjoined_relids
),
only_relids
)))
{
rel
=
make_join_rel
(
outer_rel
,
get_base_rel
(
root
,
lfirsti
(
unjoined_relids
)),
joined_rel
=
make_join_rel
(
old_rel
,
get_base_rel
(
root
,
lfirsti
(
unjoined_relids
)),
joininfo
);
join_list
=
lappend
(
join_list
,
rel
);
join_list
=
lappend
(
join_list
,
joined_
rel
);
/* Right-sided plan */
if
(
_use_right_sided_plans_
&&
length
(
o
uter
_rel
->
relids
)
>
1
)
length
(
o
ld
_rel
->
relids
)
>
1
)
{
rel
=
make_join_rel
(
joined_
rel
=
make_join_rel
(
get_base_rel
(
root
,
lfirsti
(
unjoined_relids
)),
outer
_rel
,
joininfo
);
join_list
=
lappend
(
join_list
,
rel
);
old
_rel
,
joininfo
);
join_list
=
lappend
(
join_list
,
joined_
rel
);
}
}
...
...
@@ -144,22 +143,12 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel,
Assert
(
length
(
join_rel
->
relids
)
>
1
);
if
(
is_subset
(
unjoined_relids
,
join_rel
->
relids
)
&&
nonoverlap_sets
(
o
uter
_rel
->
relids
,
join_rel
->
relids
))
nonoverlap_sets
(
o
ld
_rel
->
relids
,
join_rel
->
relids
))
{
rel
=
make_join_rel
(
outer_rel
,
join_rel
,
joininfo
);
join_list
=
lappend
(
join_list
,
rel
);
/* Right-sided plan */
if
(
_use_right_sided_plans_
&&
length
(
outer_rel
->
relids
)
>
1
)
{
rel
=
make_join_rel
(
join_rel
,
outer_rel
,
joininfo
);
join_list
=
lappend
(
join_list
,
rel
);
}
joined_rel
=
make_join_rel
(
old_rel
,
join_rel
,
joininfo
);
join_list
=
lappend
(
join_list
,
joined_rel
);
}
}
}
...
...
@@ -178,7 +167,7 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *outer_rel,
* Returns a list of new join relations.
*/
List
*
make_rels_by_clauseless_joins
(
RelOptInfo
*
o
uter
_rel
,
List
*
inner_rels
)
make_rels_by_clauseless_joins
(
RelOptInfo
*
o
ld
_rel
,
List
*
inner_rels
)
{
RelOptInfo
*
inner_rel
;
List
*
t_list
=
NIL
;
...
...
@@ -187,10 +176,10 @@ make_rels_by_clauseless_joins(RelOptInfo *outer_rel, List *inner_rels)
foreach
(
i
,
inner_rels
)
{
inner_rel
=
(
RelOptInfo
*
)
lfirst
(
i
);
if
(
nonoverlap_sets
(
inner_rel
->
relids
,
o
uter
_rel
->
relids
))
if
(
nonoverlap_sets
(
inner_rel
->
relids
,
o
ld
_rel
->
relids
))
{
t_list
=
lappend
(
t_list
,
make_join_rel
(
o
uter
_rel
,
make_join_rel
(
o
ld
_rel
,
inner_rel
,
(
JoinInfo
*
)
NULL
));
}
...
...
@@ -223,11 +212,9 @@ make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo)
* of the outer and inner join relations and then merging the results
* together.
*/
new_outer_tlist
=
new_join_tlist
(
outer_rel
->
targetlist
,
/* XXX 1-based attnos */
inner_rel
->
relids
,
1
);
new_inner_tlist
=
new_join_tlist
(
inner_rel
->
targetlist
,
/* XXX 1-based attnos */
outer_rel
->
relids
,
length
(
new_outer_tlist
)
+
1
);
new_outer_tlist
=
new_join_tlist
(
outer_rel
->
targetlist
,
1
);
new_inner_tlist
=
new_join_tlist
(
inner_rel
->
targetlist
,
length
(
new_outer_tlist
)
+
1
);
joinrel
->
relids
=
NIL
;
joinrel
->
indexed
=
false
;
...
...
@@ -286,7 +273,6 @@ make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo)
*/
List
*
new_join_tlist
(
List
*
tlist
,
Relids
other_relids
,
int
first_resdomno
)
{
int
resdomno
=
first_resdomno
-
1
;
...
...
src/include/optimizer/paths.h
View file @
d977ff7b
...
...
@@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: paths.h,v 1.2
1 1999/02/18 00:49:47
momjian Exp $
* $Id: paths.h,v 1.2
2 1999/02/18 04:45:36
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -77,13 +77,13 @@ extern MergeInfo *match_order_mergeinfo(PathOrder *ordering,
* joinrels.h
* routines to determine which relations to join
*/
extern
List
*
make_rels_by_joins
(
Query
*
root
,
List
*
o
uter
_rels
);
extern
List
*
make_rels_by_clause_joins
(
Query
*
root
,
RelOptInfo
*
o
uter
_rel
,
extern
List
*
make_rels_by_joins
(
Query
*
root
,
List
*
o
ld
_rels
);
extern
List
*
make_rels_by_clause_joins
(
Query
*
root
,
RelOptInfo
*
o
ld
_rel
,
List
*
joininfo_list
,
Relids
only_relids
);
extern
List
*
make_rels_by_clauseless_joins
(
RelOptInfo
*
o
uter
_rel
,
extern
List
*
make_rels_by_clauseless_joins
(
RelOptInfo
*
o
ld
_rel
,
List
*
inner_rels
);
extern
RelOptInfo
*
make_join_rel
(
RelOptInfo
*
outer_rel
,
RelOptInfo
*
inner_rel
,
JoinInfo
*
joininfo
);
extern
List
*
new_join_tlist
(
List
*
tlist
,
List
*
other_relids
,
int
first_resdomno
);
extern
List
*
new_join_tlist
(
List
*
tlist
,
int
first_resdomno
);
extern
RelOptInfo
*
get_cheapest_complete_rel
(
List
*
join_rel_list
);
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment