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
6de25f09
Commit
6de25f09
authored
Feb 11, 1999
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimizer cleanup.
parent
4ea3f728
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
45 deletions
+45
-45
src/backend/optimizer/path/joinutils.c
src/backend/optimizer/path/joinutils.c
+4
-4
src/backend/optimizer/util/keys.c
src/backend/optimizer/util/keys.c
+8
-8
src/backend/optimizer/util/ordering.c
src/backend/optimizer/util/ordering.c
+15
-15
src/backend/optimizer/util/pathnode.c
src/backend/optimizer/util/pathnode.c
+14
-14
src/include/optimizer/keys.h
src/include/optimizer/keys.h
+2
-2
src/include/optimizer/ordering.h
src/include/optimizer/ordering.h
+2
-2
No files found.
src/backend/optimizer/path/joinutils.c
View file @
6de25f09
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.1
8 1999/02/11 14:58:53
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.1
9 1999/02/11 17:00:48
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -214,12 +214,12 @@ match_paths_joinkeys(List *joinkeys,
foreach
(
i
,
paths
)
{
Path
*
path
=
(
Path
*
)
lfirst
(
i
);
int
more
_sort
;
int
better
_sort
;
key_match
=
every_func
(
joinkeys
,
path
->
pathkeys
,
which_subkey
);
if
(
pathorder_match
(
ordering
,
path
->
pathorder
,
&
more
_sort
)
&&
more
_sort
==
0
&&
if
(
pathorder_match
(
ordering
,
path
->
pathorder
,
&
better
_sort
)
&&
better
_sort
==
0
&&
length
(
joinkeys
)
==
length
(
path
->
pathkeys
)
&&
key_match
)
{
...
...
src/backend/optimizer/util/keys.c
View file @
6de25f09
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.1
5 1999/02/11 04:08:42
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.1
6 1999/02/11 17:00:48
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -118,7 +118,7 @@ extract_join_subkey(JoinKey *jk, int which_subkey)
*
*/
bool
pathkeys_match
(
List
*
keys1
,
List
*
keys2
,
int
*
long
er_key
)
pathkeys_match
(
List
*
keys1
,
List
*
keys2
,
int
*
bett
er_key
)
{
List
*
key1
,
*
key2
,
...
...
@@ -134,17 +134,17 @@ pathkeys_match(List *keys1, List *keys2, int *longer_key)
key1a
=
lnext
(
key1a
),
key2a
=
lnext
(
key2a
))
if
(
!
equal
(
lfirst
(
key1a
),
lfirst
(
key2a
)))
{
*
long
er_key
=
0
;
*
bett
er_key
=
0
;
return
false
;
}
if
(
key1a
!=
NIL
&&
key2a
==
NIL
)
{
*
long
er_key
=
1
;
*
bett
er_key
=
1
;
return
true
;
}
if
(
key1a
==
NIL
&&
key2a
!=
NIL
)
{
*
long
er_key
=
2
;
*
bett
er_key
=
2
;
return
true
;
}
}
...
...
@@ -156,15 +156,15 @@ pathkeys_match(List *keys1, List *keys2, int *longer_key)
*/
if
(
key1
!=
NIL
&&
key2
==
NIL
)
{
*
long
er_key
=
1
;
*
bett
er_key
=
1
;
return
true
;
}
if
(
key1
==
NIL
&&
key2
!=
NIL
)
{
*
long
er_key
=
2
;
*
bett
er_key
=
2
;
return
true
;
}
*
long
er_key
=
0
;
*
bett
er_key
=
0
;
return
true
;
}
...
...
src/backend/optimizer/util/ordering.c
View file @
6de25f09
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.1
2 1999/02/11 14:58:5
8 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.1
3 1999/02/11 17:00:4
8 momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -18,7 +18,7 @@
#include "optimizer/internal.h"
#include "optimizer/ordering.h"
static
bool
equal_sortops_order
(
Oid
*
ordering1
,
Oid
*
ordering2
,
int
*
more
_sort
);
static
bool
equal_sortops_order
(
Oid
*
ordering1
,
Oid
*
ordering2
,
int
*
better
_sort
);
/*
* equal-path-ordering--
...
...
@@ -28,23 +28,23 @@ static bool equal_sortops_order(Oid *ordering1, Oid *ordering2, int *more_sort);
bool
pathorder_match
(
PathOrder
*
path_ordering1
,
PathOrder
*
path_ordering2
,
int
*
more
_sort
)
int
*
better
_sort
)
{
*
more
_sort
=
0
;
*
better
_sort
=
0
;
if
(
path_ordering1
==
path_ordering2
)
return
true
;
if
(
!
path_ordering2
)
{
*
more
_sort
=
1
;
*
better
_sort
=
1
;
return
true
;
}
if
(
!
path_ordering1
)
{
*
more
_sort
=
2
;
*
better
_sort
=
2
;
return
true
;
}
...
...
@@ -58,14 +58,14 @@ pathorder_match(PathOrder *path_ordering1,
{
return
equal_sortops_order
(
path_ordering1
->
ord
.
sortop
,
path_ordering2
->
ord
.
sortop
,
more
_sort
);
better
_sort
);
}
else
if
(
path_ordering1
->
ordtype
==
MERGE_ORDER
&&
path_ordering2
->
ordtype
==
SORTOP_ORDER
)
{
if
(
!
path_ordering2
->
ord
.
sortop
)
{
*
more
_sort
=
1
;
*
better
_sort
=
1
;
return
true
;
}
return
path_ordering1
->
ord
.
merge
->
left_operator
==
path_ordering2
->
ord
.
sortop
[
0
];
...
...
@@ -74,7 +74,7 @@ pathorder_match(PathOrder *path_ordering1,
{
if
(
!
path_ordering1
->
ord
.
sortop
)
{
*
more
_sort
=
2
;
*
better
_sort
=
2
;
return
true
;
}
return
path_ordering1
->
ord
.
sortop
[
0
]
==
path_ordering2
->
ord
.
merge
->
left_operator
;
...
...
@@ -127,24 +127,24 @@ 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
,
int
*
more
_sort
)
equal_sortops_order
(
Oid
*
ordering1
,
Oid
*
ordering2
,
int
*
better
_sort
)
{
int
i
=
0
;
*
more
_sort
=
0
;
*
better
_sort
=
0
;
if
(
ordering1
==
ordering2
)
return
true
;
if
(
!
ordering2
)
{
*
more
_sort
=
1
;
*
better
_sort
=
1
;
return
true
;
}
if
(
!
ordering1
)
{
*
more
_sort
=
2
;
*
better
_sort
=
2
;
return
true
;
}
...
...
@@ -157,13 +157,13 @@ equal_sortops_order(Oid *ordering1, Oid *ordering2, int *more_sort)
if
(
ordering1
[
i
]
!=
0
&&
ordering2
[
i
]
==
0
)
{
*
more
_sort
=
1
;
*
better
_sort
=
1
;
return
true
;
}
if
(
ordering1
[
i
]
==
0
&&
ordering2
[
i
]
!=
0
)
{
*
more
_sort
=
2
;
*
better
_sort
=
2
;
return
true
;
}
...
...
src/backend/optimizer/util/pathnode.c
View file @
6de25f09
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.2
7 1999/02/11 16:09:41
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.2
8 1999/02/11 17:00:49
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -157,16 +157,16 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
{
Path
*
path
=
(
Path
*
)
NULL
;
List
*
temp
=
NIL
;
int
long
er_key
;
int
more
_sort
;
int
bett
er_key
;
int
better
_sort
;
foreach
(
temp
,
unique_paths
)
{
path
=
(
Path
*
)
lfirst
(
temp
);
#ifdef OPTDUP_DEBUG
if
(
!
pathkeys_match
(
new_path
->
pathkeys
,
path
->
pathkeys
,
&
long
er_key
)
||
long
er_key
!=
0
)
if
(
!
pathkeys_match
(
new_path
->
pathkeys
,
path
->
pathkeys
,
&
bett
er_key
)
||
bett
er_key
!=
0
)
{
printf
(
"oldpath
\n
"
);
pprint
(
path
->
pathkeys
);
...
...
@@ -177,7 +177,7 @@ 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
(
!
pathorder_match
(
new_path
->
pathorder
,
path
->
pathorder
,
&
more
_sort
))
if
(
!
pathorder_match
(
new_path
->
pathorder
,
path
->
pathorder
,
&
better
_sort
))
{
printf
(
"oldord
\n
"
);
pprint
(
path
->
pathorder
);
...
...
@@ -186,9 +186,9 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
}
#endif
if
(
pathkeys_match
(
new_path
->
pathkeys
,
path
->
pathkeys
,
&
long
er_key
))
if
(
pathkeys_match
(
new_path
->
pathkeys
,
path
->
pathkeys
,
&
bett
er_key
))
{
if
(
pathorder_match
(
new_path
->
pathorder
,
path
->
pathorder
,
&
more
_sort
))
if
(
pathorder_match
(
new_path
->
pathorder
,
path
->
pathorder
,
&
better
_sort
))
{
/*
* Replace pathkeys that match exactly, (1,2), (1,2).
...
...
@@ -198,12 +198,12 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
* over unsorted keys in the same way.
*/
/* same keys, and new is cheaper, use it */
if
((
longer_key
==
0
&&
more
_sort
==
0
&&
if
((
better_key
==
0
&&
better
_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
))
&&
((
better_key
==
1
&&
better
_sort
!=
2
)
||
(
better_key
!=
2
&&
better
_sort
==
1
))
&&
new_path
->
path_cost
<=
path
->
path_cost
)
{
*
is_new
=
false
;
...
...
@@ -212,12 +212,12 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
/* same keys, new is more expensive, stop */
else
if
((
longer_key
==
0
&&
more
_sort
==
0
&&
((
better_key
==
0
&&
better
_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
))
&&
((
better_key
==
2
&&
better
_sort
!=
1
)
||
(
better_key
!=
1
&&
better
_sort
==
2
))
&&
new_path
->
path_cost
>=
path
->
path_cost
)
{
*
is_new
=
false
;
...
...
src/include/optimizer/keys.h
View file @
6de25f09
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: keys.h,v 1.1
0 1999/02/11 04:08:44
momjian Exp $
* $Id: keys.h,v 1.1
1 1999/02/11 17:00:49
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -18,7 +18,7 @@
extern
bool
match_indexkey_operand
(
int
indexkey
,
Var
*
operand
,
RelOptInfo
*
rel
);
extern
Var
*
extract_join_subkey
(
JoinKey
*
jk
,
int
which_subkey
);
extern
bool
pathkeys_match
(
List
*
keys1
,
List
*
keys2
,
int
*
long
er_key
);
extern
bool
pathkeys_match
(
List
*
keys1
,
List
*
keys2
,
int
*
bett
er_key
);
extern
List
*
collect_index_pathkeys
(
int
*
index_keys
,
List
*
tlist
);
#endif
/* KEYS_H */
src/include/optimizer/ordering.h
View file @
6de25f09
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: ordering.h,v 1.1
1 1999/02/11 14:59:0
9 momjian Exp $
* $Id: ordering.h,v 1.1
2 1999/02/11 17:00:4
9 momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -16,7 +16,7 @@
#include <nodes/relation.h>
extern
bool
pathorder_match
(
PathOrder
*
path_ordering1
,
PathOrder
*
path_ordering2
,
int
*
more
_sort
);
PathOrder
*
path_ordering2
,
int
*
better
_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