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
d244df95
Commit
d244df95
authored
Feb 11, 1999
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More optimizer speedups.
parent
129543e2
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
192 additions
and
131 deletions
+192
-131
src/backend/nodes/copyfuncs.c
src/backend/nodes/copyfuncs.c
+9
-9
src/backend/nodes/equalfuncs.c
src/backend/nodes/equalfuncs.c
+11
-11
src/backend/nodes/freefuncs.c
src/backend/nodes/freefuncs.c
+6
-6
src/backend/nodes/outfuncs.c
src/backend/nodes/outfuncs.c
+11
-11
src/backend/nodes/readfuncs.c
src/backend/nodes/readfuncs.c
+11
-11
src/backend/optimizer/geqo/geqo_paths.c
src/backend/optimizer/geqo/geqo_paths.c
+2
-2
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/indxpath.c
+4
-4
src/backend/optimizer/path/joinpath.c
src/backend/optimizer/path/joinpath.c
+3
-3
src/backend/optimizer/path/joinutils.c
src/backend/optimizer/path/joinutils.c
+5
-3
src/backend/optimizer/path/mergeutils.c
src/backend/optimizer/path/mergeutils.c
+6
-6
src/backend/optimizer/path/orindxpath.c
src/backend/optimizer/path/orindxpath.c
+4
-4
src/backend/optimizer/path/prune.c
src/backend/optimizer/path/prune.c
+2
-2
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/createplan.c
+4
-4
src/backend/optimizer/util/ordering.c
src/backend/optimizer/util/ordering.c
+63
-15
src/backend/optimizer/util/pathnode.c
src/backend/optimizer/util/pathnode.c
+46
-35
src/include/nodes/relation.h
src/include/nodes/relation.h
+2
-2
src/include/optimizer/ordering.h
src/include/optimizer/ordering.h
+3
-3
No files found.
src/backend/nodes/copyfuncs.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.6
6 1999/02/10 03:52:34
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.6
7 1999/02/11 14:58:48
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1093,26 +1093,26 @@ CopyPathFields(Path *from, Path *newnode)
newnode
->
path_cost
=
from
->
path_cost
;
newnode
->
path
_
order
=
makeNode
(
PathOrder
);
newnode
->
path
_order
->
ordtype
=
from
->
path_
order
->
ordtype
;
if
(
from
->
path
_
order
->
ordtype
==
SORTOP_ORDER
)
newnode
->
pathorder
=
makeNode
(
PathOrder
);
newnode
->
path
order
->
ordtype
=
from
->
path
order
->
ordtype
;
if
(
from
->
pathorder
->
ordtype
==
SORTOP_ORDER
)
{
int
len
,
i
;
Oid
*
ordering
=
from
->
path
_
order
->
ord
.
sortop
;
Oid
*
ordering
=
from
->
pathorder
->
ord
.
sortop
;
if
(
ordering
)
{
for
(
len
=
0
;
ordering
[
len
]
!=
0
;
len
++
)
;
newnode
->
path
_
order
->
ord
.
sortop
=
(
Oid
*
)
palloc
(
sizeof
(
Oid
)
*
(
len
+
1
));
newnode
->
pathorder
->
ord
.
sortop
=
(
Oid
*
)
palloc
(
sizeof
(
Oid
)
*
(
len
+
1
));
for
(
i
=
0
;
i
<
len
;
i
++
)
newnode
->
path
_
order
->
ord
.
sortop
[
i
]
=
ordering
[
i
];
newnode
->
path
_
order
->
ord
.
sortop
[
len
]
=
0
;
newnode
->
pathorder
->
ord
.
sortop
[
i
]
=
ordering
[
i
];
newnode
->
pathorder
->
ord
.
sortop
[
len
]
=
0
;
}
}
else
Node_Copy
(
from
,
newnode
,
path
_
order
->
ord
.
merge
);
Node_Copy
(
from
,
newnode
,
pathorder
->
ord
.
merge
);
Node_Copy
(
from
,
newnode
,
pathkeys
);
...
...
src/backend/nodes/equalfuncs.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.
29 1999/02/10 21:02:33
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.
30 1999/02/11 14:58:48
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -337,33 +337,33 @@ _equalPath(Path *a, Path *b)
/*
* if (a->path_cost != b->path_cost) return(false);
*/
if
(
a
->
path
_
order
->
ordtype
==
SORTOP_ORDER
)
if
(
a
->
pathorder
->
ordtype
==
SORTOP_ORDER
)
{
int
i
=
0
;
if
(
a
->
path
_
order
->
ord
.
sortop
==
NULL
||
b
->
path
_
order
->
ord
.
sortop
==
NULL
)
if
(
a
->
pathorder
->
ord
.
sortop
==
NULL
||
b
->
pathorder
->
ord
.
sortop
==
NULL
)
{
if
(
a
->
path
_order
->
ord
.
sortop
!=
b
->
path_
order
->
ord
.
sortop
)
if
(
a
->
path
order
->
ord
.
sortop
!=
b
->
path
order
->
ord
.
sortop
)
return
false
;
}
else
{
while
(
a
->
path
_
order
->
ord
.
sortop
[
i
]
!=
0
&&
b
->
path
_
order
->
ord
.
sortop
[
i
]
!=
0
)
while
(
a
->
pathorder
->
ord
.
sortop
[
i
]
!=
0
&&
b
->
pathorder
->
ord
.
sortop
[
i
]
!=
0
)
{
if
(
a
->
path
_order
->
ord
.
sortop
[
i
]
!=
b
->
path_
order
->
ord
.
sortop
[
i
])
if
(
a
->
path
order
->
ord
.
sortop
[
i
]
!=
b
->
path
order
->
ord
.
sortop
[
i
])
return
false
;
i
++
;
}
if
(
a
->
path
_
order
->
ord
.
sortop
[
i
]
!=
0
||
b
->
path
_
order
->
ord
.
sortop
[
i
]
!=
0
)
if
(
a
->
pathorder
->
ord
.
sortop
[
i
]
!=
0
||
b
->
pathorder
->
ord
.
sortop
[
i
]
!=
0
)
return
false
;
}
}
else
{
if
(
!
equal
(
a
->
path
_order
->
ord
.
merge
,
b
->
path_
order
->
ord
.
merge
))
if
(
!
equal
(
a
->
path
order
->
ord
.
merge
,
b
->
path
order
->
ord
.
merge
))
return
false
;
}
if
(
!
equal
(
a
->
pathkeys
,
b
->
pathkeys
))
...
...
src/backend/nodes/freefuncs.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.
6 1999/02/10 21:02:33
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.
7 1999/02/11 14:58:49
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -756,15 +756,15 @@ _freeRelOptInfo(RelOptInfo *node)
static
void
FreePathFields
(
Path
*
node
)
{
if
(
node
->
path
_
order
->
ordtype
==
SORTOP_ORDER
)
if
(
node
->
pathorder
->
ordtype
==
SORTOP_ORDER
)
{
if
(
node
->
path
_
order
->
ord
.
sortop
)
pfree
(
node
->
path
_
order
->
ord
.
sortop
);
if
(
node
->
pathorder
->
ord
.
sortop
)
pfree
(
node
->
pathorder
->
ord
.
sortop
);
}
else
freeObject
(
node
->
path
_
order
->
ord
.
merge
);
freeObject
(
node
->
pathorder
->
ord
.
merge
);
pfree
(
node
->
path
_
order
);
/* is it an object, but we don't have
pfree
(
node
->
pathorder
);
/* is it an object, but we don't have
separate free for it */
freeObject
(
node
->
pathkeys
);
...
...
src/backend/nodes/outfuncs.c
View file @
d244df95
...
...
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: outfuncs.c,v 1.6
8 1999/02/10 03:52:35
momjian Exp $
* $Id: outfuncs.c,v 1.6
9 1999/02/11 14:58:49
momjian Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
...
...
@@ -964,8 +964,8 @@ _outPath(StringInfo str, Path *node)
node
->
path_cost
);
_outNode
(
str
,
node
->
pathkeys
);
appendStringInfo
(
str
,
" :path
_
order "
);
_outNode
(
str
,
node
->
path
_
order
);
appendStringInfo
(
str
,
" :pathorder "
);
_outNode
(
str
,
node
->
pathorder
);
}
/*
...
...
@@ -980,8 +980,8 @@ _outIndexPath(StringInfo str, IndexPath *node)
node
->
path
.
path_cost
);
_outNode
(
str
,
node
->
path
.
pathkeys
);
appendStringInfo
(
str
,
" :path
_
order "
);
_outNode
(
str
,
node
->
path
.
path
_
order
);
appendStringInfo
(
str
,
" :pathorder "
);
_outNode
(
str
,
node
->
path
.
pathorder
);
appendStringInfo
(
str
,
" :indexid "
);
_outIntList
(
str
,
node
->
indexid
);
...
...
@@ -1002,8 +1002,8 @@ _outJoinPath(StringInfo str, JoinPath *node)
node
->
path
.
path_cost
);
_outNode
(
str
,
node
->
path
.
pathkeys
);
appendStringInfo
(
str
,
" :path
_
order "
);
_outNode
(
str
,
node
->
path
.
path
_
order
);
appendStringInfo
(
str
,
" :pathorder "
);
_outNode
(
str
,
node
->
path
.
pathorder
);
appendStringInfo
(
str
,
" :pathinfo "
);
_outNode
(
str
,
node
->
pathinfo
);
...
...
@@ -1033,8 +1033,8 @@ _outMergePath(StringInfo str, MergePath *node)
node
->
jpath
.
path
.
path_cost
);
_outNode
(
str
,
node
->
jpath
.
path
.
pathkeys
);
appendStringInfo
(
str
,
" :path
_
order "
);
_outNode
(
str
,
node
->
jpath
.
path
.
path
_
order
);
appendStringInfo
(
str
,
" :pathorder "
);
_outNode
(
str
,
node
->
jpath
.
path
.
pathorder
);
appendStringInfo
(
str
,
" :pathinfo "
);
_outNode
(
str
,
node
->
jpath
.
pathinfo
);
...
...
@@ -1073,8 +1073,8 @@ _outHashPath(StringInfo str, HashPath *node)
node
->
jpath
.
path
.
path_cost
);
_outNode
(
str
,
node
->
jpath
.
path
.
pathkeys
);
appendStringInfo
(
str
,
" :path
_
order "
);
_outNode
(
str
,
node
->
jpath
.
path
.
path
_
order
);
appendStringInfo
(
str
,
" :pathorder "
);
_outNode
(
str
,
node
->
jpath
.
path
.
pathorder
);
appendStringInfo
(
str
,
" :pathinfo "
);
_outNode
(
str
,
node
->
jpath
.
pathinfo
);
...
...
src/backend/nodes/readfuncs.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.5
3 1999/02/10 03:52:36
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.5
4 1999/02/11 14:58:49
momjian Exp $
*
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
...
...
@@ -1522,8 +1522,8 @@ _readPath()
token
=
lsptok
(
NULL
,
&
length
);
/* now read it */
local_node
->
path_cost
=
(
Cost
)
atof
(
token
);
token
=
lsptok
(
NULL
,
&
length
);
/* get :path
_
order */
local_node
->
path
_
order
=
nodeRead
(
true
);
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :pathorder */
local_node
->
pathorder
=
nodeRead
(
true
);
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :pathkeys */
local_node
->
pathkeys
=
nodeRead
(
true
);
/* now read it */
...
...
@@ -1554,8 +1554,8 @@ _readIndexPath()
token
=
lsptok
(
NULL
,
&
length
);
/* now read it */
local_node
->
path
.
path_cost
=
(
Cost
)
atof
(
token
);
token
=
lsptok
(
NULL
,
&
length
);
/* get :path
_
order */
local_node
->
path
.
path
_
order
=
nodeRead
(
true
);
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :pathorder */
local_node
->
path
.
pathorder
=
nodeRead
(
true
);
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :pathkeys */
local_node
->
path
.
pathkeys
=
nodeRead
(
true
);
/* now read it */
...
...
@@ -1593,8 +1593,8 @@ _readJoinPath()
token
=
lsptok
(
NULL
,
&
length
);
/* now read it */
local_node
->
path
.
path_cost
=
(
Cost
)
atof
(
token
);
token
=
lsptok
(
NULL
,
&
length
);
/* get :path
_
order */
local_node
->
path
.
path
_
order
=
nodeRead
(
true
);
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :pathorder */
local_node
->
path
.
pathorder
=
nodeRead
(
true
);
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :pathkeys */
local_node
->
path
.
pathkeys
=
nodeRead
(
true
);
/* now read it */
...
...
@@ -1658,8 +1658,8 @@ _readMergePath()
local_node
->
jpath
.
path
.
path_cost
=
(
Cost
)
atof
(
token
);
token
=
lsptok
(
NULL
,
&
length
);
/* get :path
_
order */
local_node
->
jpath
.
path
.
path
_
order
=
nodeRead
(
true
);
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :pathorder */
local_node
->
jpath
.
path
.
pathorder
=
nodeRead
(
true
);
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :pathkeys */
local_node
->
jpath
.
path
.
pathkeys
=
nodeRead
(
true
);
/* now read it */
...
...
@@ -1732,8 +1732,8 @@ _readHashPath()
local_node
->
jpath
.
path
.
path_cost
=
(
Cost
)
atof
(
token
);
token
=
lsptok
(
NULL
,
&
length
);
/* get :path
_
order */
local_node
->
jpath
.
path
.
path
_
order
=
nodeRead
(
true
);
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :pathorder */
local_node
->
jpath
.
path
.
pathorder
=
nodeRead
(
true
);
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :pathkeys */
local_node
->
jpath
.
path
.
pathkeys
=
nodeRead
(
true
);
/* now read it */
...
...
src/backend/optimizer/geqo/geqo_paths.c
View file @
d244df95
...
...
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: geqo_paths.c,v 1.1
5 1999/02/10 21:02:35
momjian Exp $
* $Id: geqo_paths.c,v 1.1
6 1999/02/11 14:58:50
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -113,7 +113,7 @@ geqo_rel_paths(RelOptInfo *rel)
{
path
=
(
Path
*
)
lfirst
(
y
);
if
(
!
path
->
path
_
order
->
ord
.
sortop
)
if
(
!
path
->
pathorder
->
ord
.
sortop
)
break
;
}
...
...
src/backend/optimizer/path/indxpath.c
View file @
d244df95
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.4
2 1999/02/10 21:02:38
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.4
3 1999/02/11 14:58:50
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1290,9 +1290,9 @@ index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list,
pathnode
->
path
.
pathtype
=
T_IndexScan
;
pathnode
->
path
.
parent
=
rel
;
pathnode
->
path
.
path
_
order
=
makeNode
(
PathOrder
);
pathnode
->
path
.
path
_
order
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
path
.
path
_
order
->
ord
.
sortop
=
index
->
ordering
;
pathnode
->
path
.
pathorder
=
makeNode
(
PathOrder
);
pathnode
->
path
.
pathorder
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
path
.
pathorder
->
ord
.
sortop
=
index
->
ordering
;
pathnode
->
path
.
pathkeys
=
NIL
;
pathnode
->
indexid
=
index
->
relids
;
...
...
src/backend/optimizer/path/joinpath.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.
19 1999/02/10 21:02:38
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.
20 1999/02/11 14:58:52
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -327,7 +327,7 @@ match_unsorted_outer(RelOptInfo *joinrel,
outerpath
=
(
Path
*
)
lfirst
(
i
);
outerpath_ordering
=
outerpath
->
path
_
order
;
outerpath_ordering
=
outerpath
->
pathorder
;
if
(
outerpath_ordering
)
{
...
...
@@ -470,7 +470,7 @@ match_unsorted_inner(RelOptInfo *joinrel,
innerpath
=
(
Path
*
)
lfirst
(
i
);
innerpath_ordering
=
innerpath
->
path
_
order
;
innerpath_ordering
=
innerpath
->
pathorder
;
if
(
innerpath_ordering
)
{
...
...
src/backend/optimizer/path/joinutils.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.1
7 1999/02/11 05:29:07
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.1
8 1999/02/11 14:58:53
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -214,10 +214,12 @@ match_paths_joinkeys(List *joinkeys,
foreach
(
i
,
paths
)
{
Path
*
path
=
(
Path
*
)
lfirst
(
i
);
int
more_sort
;
key_match
=
every_func
(
joinkeys
,
path
->
pathkeys
,
which_subkey
);
if
(
equal_path_ordering
(
ordering
,
path
->
path_order
)
&&
if
(
pathorder_match
(
ordering
,
path
->
pathorder
,
&
more_sort
)
&&
more_sort
==
0
&&
length
(
joinkeys
)
==
length
(
path
->
pathkeys
)
&&
key_match
)
{
...
...
src/backend/optimizer/path/mergeutils.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.1
6 1999/02/10 03:52:41
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.1
7 1999/02/11 14:58:53
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -52,17 +52,17 @@ group_clauses_by_order(List *restrictinfo_list,
* Create a new mergeinfo node and add it to 'mergeinfo-list'
* if one does not yet exist for this merge ordering.
*/
PathOrder
*
path
_
order
;
PathOrder
*
pathorder
;
MergeInfo
*
xmergeinfo
;
Expr
*
clause
=
restrictinfo
->
clause
;
Var
*
leftop
=
get_leftop
(
clause
);
Var
*
rightop
=
get_rightop
(
clause
);
JoinKey
*
jmkeys
;
path
_
order
=
makeNode
(
PathOrder
);
path
_
order
->
ordtype
=
MERGE_ORDER
;
path
_
order
->
ord
.
merge
=
merge_ordering
;
xmergeinfo
=
match_order_mergeinfo
(
path
_
order
,
mergeinfo_list
);
pathorder
=
makeNode
(
PathOrder
);
pathorder
->
ordtype
=
MERGE_ORDER
;
pathorder
->
ord
.
merge
=
merge_ordering
;
xmergeinfo
=
match_order_mergeinfo
(
pathorder
,
mergeinfo_list
);
if
(
inner_relid
==
leftop
->
varno
)
{
jmkeys
=
makeNode
(
JoinKey
);
...
...
src/backend/optimizer/path/orindxpath.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.1
8 1999/02/10 21:02:39
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.1
9 1999/02/11 14:58:53
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -104,14 +104,14 @@ create_or_index_paths(Query *root,
pathnode
->
path
.
pathtype
=
T_IndexScan
;
pathnode
->
path
.
parent
=
rel
;
pathnode
->
path
.
path
_
order
=
makeNode
(
PathOrder
);
pathnode
->
path
.
path
_
order
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
path
.
pathorder
=
makeNode
(
PathOrder
);
pathnode
->
path
.
pathorder
->
ordtype
=
SORTOP_ORDER
;
/*
* This is an IndexScan, but it does index lookups based
* on the order of the fields specified in the WHERE clause,
* not in any order, so the sortop is NULL.
*/
pathnode
->
path
.
path
_
order
->
ord
.
sortop
=
NULL
;
pathnode
->
path
.
pathorder
->
ord
.
sortop
=
NULL
;
pathnode
->
path
.
pathkeys
=
NIL
;
pathnode
->
indexqual
=
lcons
(
clausenode
,
NIL
);
...
...
src/backend/optimizer/path/prune.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.2
6 1999/02/10 21:02:40
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.2
7 1999/02/11 14:58:54
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -109,7 +109,7 @@ prune_rel_paths(List *rel_list)
{
path
=
(
Path
*
)
lfirst
(
y
);
if
(
!
path
->
path
_
order
->
ord
.
sortop
)
if
(
!
path
->
pathorder
->
ord
.
sortop
)
break
;
}
cheapest
=
(
JoinPath
*
)
prune_rel_path
(
rel
,
path
);
...
...
src/backend/optimizer/plan/createplan.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.4
2 1999/02/10 17:14:30
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.4
3 1999/02/11 14:58:54
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -529,14 +529,14 @@ create_mergejoin_node(MergePath *best_path,
outer_tlist
,
inner_tlist
));
opcode
=
get_opcode
((
best_path
->
jpath
.
path
.
path
_
order
->
ord
.
merge
)
->
join_operator
);
opcode
=
get_opcode
((
best_path
->
jpath
.
path
.
pathorder
->
ord
.
merge
)
->
join_operator
);
outer_order
=
(
Oid
*
)
palloc
(
sizeof
(
Oid
)
*
2
);
outer_order
[
0
]
=
(
best_path
->
jpath
.
path
.
path
_
order
->
ord
.
merge
)
->
left_operator
;
outer_order
[
0
]
=
(
best_path
->
jpath
.
path
.
pathorder
->
ord
.
merge
)
->
left_operator
;
outer_order
[
1
]
=
0
;
inner_order
=
(
Oid
*
)
palloc
(
sizeof
(
Oid
)
*
2
);
inner_order
[
0
]
=
(
best_path
->
jpath
.
path
.
path
_
order
->
ord
.
merge
)
->
right_operator
;
inner_order
[
0
]
=
(
best_path
->
jpath
.
path
.
pathorder
->
ord
.
merge
)
->
right_operator
;
inner_order
[
1
]
=
0
;
/*
...
...
src/backend/optimizer/util/ordering.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.1
1 1999/02/06 17:29:27
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.1
2 1999/02/11 14:58:58
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -18,7 +18,7 @@
#include "optimizer/internal.h"
#include "optimizer/ordering.h"
static
bool
equal_sortops_order
(
Oid
*
ordering1
,
Oid
*
ordering2
);
static
bool
equal_sortops_order
(
Oid
*
ordering1
,
Oid
*
ordering2
,
int
*
more_sort
);
/*
* equal-path-ordering--
...
...
@@ -26,14 +26,27 @@ static bool equal_sortops_order(Oid *ordering1, Oid *ordering2);
*
*/
bool
equal_path_ordering
(
PathOrder
*
path_ordering1
,
PathOrder
*
path_ordering2
)
pathorder_match
(
PathOrder
*
path_ordering1
,
PathOrder
*
path_ordering2
,
int
*
more_sort
)
{
*
more_sort
=
0
;
if
(
path_ordering1
==
path_ordering2
)
return
true
;
if
(
!
path_ordering1
||
!
path_ordering2
)
return
false
;
if
(
!
path_ordering2
)
{
*
more_sort
=
1
;
return
true
;
}
if
(
!
path_ordering1
)
{
*
more_sort
=
2
;
return
true
;
}
if
(
path_ordering1
->
ordtype
==
MERGE_ORDER
&&
path_ordering2
->
ordtype
==
MERGE_ORDER
)
...
...
@@ -43,19 +56,28 @@ equal_path_ordering(PathOrder *path_ordering1,
else
if
(
path_ordering1
->
ordtype
==
SORTOP_ORDER
&&
path_ordering2
->
ordtype
==
SORTOP_ORDER
)
{
return
(
equal_sortops_order
(
path_ordering1
->
ord
.
sortop
,
path_ordering2
->
ord
.
sortop
));
return
equal_sortops_order
(
path_ordering1
->
ord
.
sortop
,
path_ordering2
->
ord
.
sortop
,
more_sort
);
}
else
if
(
path_ordering1
->
ordtype
==
MERGE_ORDER
&&
path_ordering2
->
ordtype
==
SORTOP_ORDER
)
{
return
(
path_ordering2
->
ord
.
sortop
&&
(
path_ordering1
->
ord
.
merge
->
left_operator
==
path_ordering2
->
ord
.
sortop
[
0
]));
if
(
!
path_ordering2
->
ord
.
sortop
)
{
*
more_sort
=
1
;
return
true
;
}
return
path_ordering1
->
ord
.
merge
->
left_operator
==
path_ordering2
->
ord
.
sortop
[
0
];
}
else
{
return
(
path_ordering1
->
ord
.
sortop
&&
(
path_ordering1
->
ord
.
sortop
[
0
]
==
path_ordering2
->
ord
.
merge
->
left_operator
));
if
(
!
path_ordering1
->
ord
.
sortop
)
{
*
more_sort
=
2
;
return
true
;
}
return
path_ordering1
->
ord
.
sortop
[
0
]
==
path_ordering2
->
ord
.
merge
->
left_operator
;
}
}
...
...
@@ -105,12 +127,26 @@ equal_merge_ordering(MergeOrder *merge_ordering1,
* Returns true iff the sort operators are in the same order.
*/
static
bool
equal_sortops_order
(
Oid
*
ordering1
,
Oid
*
ordering2
)
equal_sortops_order
(
Oid
*
ordering1
,
Oid
*
ordering2
,
int
*
more_sort
)
{
int
i
=
0
;
if
(
ordering1
==
NULL
||
ordering2
==
NULL
)
return
ordering1
==
ordering2
;
*
more_sort
=
0
;
if
(
ordering1
==
ordering2
)
return
true
;
if
(
!
ordering2
)
{
*
more_sort
=
1
;
return
true
;
}
if
(
!
ordering1
)
{
*
more_sort
=
2
;
return
true
;
}
while
(
ordering1
[
i
]
!=
0
&&
ordering2
[
i
]
!=
0
)
{
...
...
@@ -119,5 +155,17 @@ equal_sortops_order(Oid *ordering1, Oid *ordering2)
i
++
;
}
if
(
ordering1
[
i
]
!=
0
&&
ordering2
[
i
]
==
0
)
{
*
more_sort
=
1
;
return
true
;
}
if
(
ordering1
[
i
]
==
0
&&
ordering2
[
i
]
!=
0
)
{
*
more_sort
=
2
;
return
true
;
}
return
ordering1
[
i
]
==
0
&&
ordering2
[
i
]
==
0
;
}
src/backend/optimizer/util/pathnode.c
View file @
d244df95
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.2
5 1999/02/11 05:29:08
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.2
6 1999/02/11 14:59:02
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -158,6 +158,7 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
Path
*
path
=
(
Path
*
)
NULL
;
List
*
temp
=
NIL
;
int
longer_key
;
int
more_sort
;
foreach
(
temp
,
unique_paths
)
{
...
...
@@ -176,18 +177,18 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
length
(
lfirst
(
path
->
pathkeys
))
<
length
(
lfirst
(
new_path
->
pathkeys
)))
sleep
(
0
);
/* set breakpoint here */
}
if
(
!
equal_path_ordering
(
new_path
->
path_order
,
path
->
path_order
))
if
(
!
pathorder_match
(
new_path
->
pathorder
,
path
->
pathorder
,
&
more_sort
))
{
printf
(
"oldord
\n
"
);
pprint
(
path
->
path
_
order
);
pprint
(
path
->
pathorder
);
printf
(
"neword
\n
"
);
pprint
(
new_path
->
path
_
order
);
pprint
(
new_path
->
pathorder
);
}
#endif
if
(
pathkeys_match
(
new_path
->
pathkeys
,
path
->
pathkeys
,
&
longer_key
))
{
if
(
equal_path_ordering
(
new_path
->
path_order
,
path
->
path_order
))
if
(
pathorder_match
(
new_path
->
pathorder
,
path
->
pathorder
,
&
more_sort
))
{
/*
* Replace pathkeys that match exactly, (1,2), (1,2).
...
...
@@ -197,17 +198,27 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
*/
/* same keys, and new is cheaper, use it */
if
((
longer_key
==
0
&&
new_path
->
path_cost
<
path
->
path_cost
)
||
/* new is longer, and cheaper, use it */
(
longer_key
==
1
&&
new_path
->
path_cost
<=
path
->
path_cost
))
if
((
longer_key
==
0
&&
more_sort
==
0
&&
new_path
->
path_cost
<
path
->
path_cost
)
||
/* new is better, and cheaper, use it */
((
longer_key
==
1
&&
more_sort
!=
2
)
||
(
longer_key
!=
2
&&
more_sort
==
1
))
&&
new_path
->
path_cost
<=
path
->
path_cost
)
{
*
is_new
=
false
;
return
new_path
;
}
/* same keys, new is more expensive, stop */
else
if
((
longer_key
==
0
&&
new_path
->
path_cost
>=
path
->
path_cost
)
||
/* old is longer, and less expensive, stop */
(
longer_key
==
2
&&
new_path
->
path_cost
>=
path
->
path_cost
))
else
if
((
longer_key
==
0
&&
more_sort
==
0
&&
new_path
->
path_cost
>=
path
->
path_cost
)
||
/* old is better, and less expensive, stop */
((
longer_key
==
2
&&
more_sort
!=
1
)
||
(
longer_key
!=
1
&&
more_sort
==
2
))
&&
new_path
->
path_cost
>=
path
->
path_cost
)
{
*
is_new
=
false
;
return
NULL
;
...
...
@@ -242,9 +253,9 @@ create_seqscan_path(RelOptInfo *rel)
pathnode
->
pathtype
=
T_SeqScan
;
pathnode
->
parent
=
rel
;
pathnode
->
path_cost
=
0
.
0
;
pathnode
->
path
_
order
=
makeNode
(
PathOrder
);
pathnode
->
path
_
order
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
path
_
order
->
ord
.
sortop
=
NULL
;
pathnode
->
pathorder
=
makeNode
(
PathOrder
);
pathnode
->
pathorder
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
pathorder
->
ord
.
sortop
=
NULL
;
pathnode
->
pathkeys
=
NIL
;
/*
...
...
@@ -292,9 +303,9 @@ create_index_path(Query *root,
pathnode
->
path
.
pathtype
=
T_IndexScan
;
pathnode
->
path
.
parent
=
rel
;
pathnode
->
path
.
path
_
order
=
makeNode
(
PathOrder
);
pathnode
->
path
.
path
_
order
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
path
.
path
_
order
->
ord
.
sortop
=
index
->
ordering
;
pathnode
->
path
.
pathorder
=
makeNode
(
PathOrder
);
pathnode
->
path
.
pathorder
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
path
.
pathorder
->
ord
.
sortop
=
index
->
ordering
;
pathnode
->
indexid
=
index
->
relids
;
pathnode
->
indexkeys
=
index
->
indexkeys
;
...
...
@@ -311,7 +322,7 @@ create_index_path(Query *root,
* The index must have an ordering for the path to have (ordering)
* keys, and vice versa.
*/
if
(
pathnode
->
path
.
path
_
order
->
ord
.
sortop
)
if
(
pathnode
->
path
.
pathorder
->
ord
.
sortop
)
{
pathnode
->
path
.
pathkeys
=
collect_index_pathkeys
(
index
->
indexkeys
,
rel
->
targetlist
);
...
...
@@ -323,7 +334,7 @@ create_index_path(Query *root,
* if no index keys were found, we can't order the path).
*/
if
(
pathnode
->
path
.
pathkeys
==
NULL
)
pathnode
->
path
.
path
_
order
->
ord
.
sortop
=
NULL
;
pathnode
->
path
.
pathorder
->
ord
.
sortop
=
NULL
;
}
else
pathnode
->
path
.
pathkeys
=
NULL
;
...
...
@@ -449,20 +460,20 @@ create_nestloop_path(RelOptInfo *joinrel,
pathnode
->
path
.
joinid
=
NIL
;
pathnode
->
path
.
outerjoincost
=
(
Cost
)
0
.
0
;
pathnode
->
path
.
loc_restrictinfo
=
NIL
;
pathnode
->
path
.
path
_
order
=
makeNode
(
PathOrder
);
pathnode
->
path
.
pathorder
=
makeNode
(
PathOrder
);
if
(
pathkeys
)
{
pathnode
->
path
.
path
_order
->
ordtype
=
outer_path
->
path_
order
->
ordtype
;
if
(
outer_path
->
path
_
order
->
ordtype
==
SORTOP_ORDER
)
pathnode
->
path
.
path
_order
->
ord
.
sortop
=
outer_path
->
path_
order
->
ord
.
sortop
;
pathnode
->
path
.
path
order
->
ordtype
=
outer_path
->
path
order
->
ordtype
;
if
(
outer_path
->
pathorder
->
ordtype
==
SORTOP_ORDER
)
pathnode
->
path
.
path
order
->
ord
.
sortop
=
outer_path
->
path
order
->
ord
.
sortop
;
else
pathnode
->
path
.
path
_order
->
ord
.
merge
=
outer_path
->
path_
order
->
ord
.
merge
;
pathnode
->
path
.
path
order
->
ord
.
merge
=
outer_path
->
path
order
->
ord
.
merge
;
}
else
{
pathnode
->
path
.
path
_
order
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
path
.
path
_
order
->
ord
.
sortop
=
NULL
;
pathnode
->
path
.
pathorder
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
path
.
pathorder
->
ord
.
sortop
=
NULL
;
}
pathnode
->
path
.
path_cost
=
cost_nestloop
(
outer_path
->
path_cost
,
...
...
@@ -521,9 +532,9 @@ create_mergejoin_path(RelOptInfo *joinrel,
pathnode
->
jpath
.
innerjoinpath
=
inner_path
;
pathnode
->
jpath
.
pathinfo
=
joinrel
->
restrictinfo
;
pathnode
->
jpath
.
path
.
pathkeys
=
pathkeys
;
pathnode
->
jpath
.
path
.
path
_
order
=
makeNode
(
PathOrder
);
pathnode
->
jpath
.
path
.
path
_
order
->
ordtype
=
MERGE_ORDER
;
pathnode
->
jpath
.
path
.
path
_
order
->
ord
.
merge
=
order
;
pathnode
->
jpath
.
path
.
pathorder
=
makeNode
(
PathOrder
);
pathnode
->
jpath
.
path
.
pathorder
->
ordtype
=
MERGE_ORDER
;
pathnode
->
jpath
.
path
.
pathorder
->
ord
.
merge
=
order
;
pathnode
->
path_mergeclauses
=
mergeclauses
;
pathnode
->
jpath
.
path
.
loc_restrictinfo
=
NIL
;
pathnode
->
outersortkeys
=
outersortkeys
;
...
...
@@ -587,9 +598,9 @@ create_hashjoin_path(RelOptInfo *joinrel,
pathnode
->
jpath
.
pathinfo
=
joinrel
->
restrictinfo
;
pathnode
->
jpath
.
path
.
loc_restrictinfo
=
NIL
;
pathnode
->
jpath
.
path
.
pathkeys
=
pathkeys
;
pathnode
->
jpath
.
path
.
path
_
order
=
makeNode
(
PathOrder
);
pathnode
->
jpath
.
path
.
path
_
order
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
jpath
.
path
.
path
_
order
->
ord
.
sortop
=
NULL
;
pathnode
->
jpath
.
path
.
pathorder
=
makeNode
(
PathOrder
);
pathnode
->
jpath
.
path
.
pathorder
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
jpath
.
path
.
pathorder
->
ord
.
sortop
=
NULL
;
pathnode
->
jpath
.
path
.
outerjoincost
=
(
Cost
)
0
.
0
;
pathnode
->
jpath
.
path
.
joinid
=
(
Relid
)
NULL
;
/* pathnode->hashjoinoperator = operator; */
...
...
src/include/nodes/relation.h
View file @
d244df95
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: relation.h,v 1.1
8 1999/02/10 03:52:50
momjian Exp $
* $Id: relation.h,v 1.1
9 1999/02/11 14:59:03
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -146,7 +146,7 @@ typedef struct Path
NodeTag
pathtype
;
PathOrder
*
path
_
order
;
PathOrder
*
pathorder
;
List
*
pathkeys
;
/* This is a List of List of Var nodes.
* It is a List of Lists because of multi-key
...
...
src/include/optimizer/ordering.h
View file @
d244df95
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: ordering.h,v 1.1
0 1999/02/06 17:29:30
momjian Exp $
* $Id: ordering.h,v 1.1
1 1999/02/11 14:59:09
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -15,8 +15,8 @@
#include <nodes/relation.h>
extern
bool
equal_path_ordering
(
PathOrder
*
path_ordering1
,
PathOrder
*
path_ordering2
);
extern
bool
pathorder_match
(
PathOrder
*
path_ordering1
,
PathOrder
*
path_ordering2
,
int
*
more_sort
);
extern
bool
equal_path_merge_ordering
(
Oid
*
path_ordering
,
MergeOrder
*
merge_ordering
);
extern
bool
equal_merge_ordering
(
MergeOrder
*
merge_ordering1
,
...
...
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