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
34ecb9d8
Commit
34ecb9d8
authored
Feb 11, 1999
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimizer cleanups.
parent
c873fcda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
45 deletions
+49
-45
src/backend/optimizer/util/ordering.c
src/backend/optimizer/util/ordering.c
+6
-5
src/backend/optimizer/util/pathnode.c
src/backend/optimizer/util/pathnode.c
+43
-40
No files found.
src/backend/optimizer/util/ordering.c
View file @
34ecb9d8
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.1
3 1999/02/11 17:00:4
8 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.1
4 1999/02/11 21:05:2
8 momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -18,7 +18,8 @@
...
@@ -18,7 +18,8 @@
#include "optimizer/internal.h"
#include "optimizer/internal.h"
#include "optimizer/ordering.h"
#include "optimizer/ordering.h"
static
bool
equal_sortops_order
(
Oid
*
ordering1
,
Oid
*
ordering2
,
int
*
better_sort
);
static
bool
sortops_order_match
(
Oid
*
ordering1
,
Oid
*
ordering2
,
int
*
better_sort
);
/*
/*
* equal-path-ordering--
* equal-path-ordering--
...
@@ -56,7 +57,7 @@ pathorder_match(PathOrder *path_ordering1,
...
@@ -56,7 +57,7 @@ pathorder_match(PathOrder *path_ordering1,
else
if
(
path_ordering1
->
ordtype
==
SORTOP_ORDER
&&
else
if
(
path_ordering1
->
ordtype
==
SORTOP_ORDER
&&
path_ordering2
->
ordtype
==
SORTOP_ORDER
)
path_ordering2
->
ordtype
==
SORTOP_ORDER
)
{
{
return
equal_sortops_order
(
path_ordering1
->
ord
.
sortop
,
return
sortops_order_match
(
path_ordering1
->
ord
.
sortop
,
path_ordering2
->
ord
.
sortop
,
path_ordering2
->
ord
.
sortop
,
better_sort
);
better_sort
);
}
}
...
@@ -127,7 +128,7 @@ equal_merge_ordering(MergeOrder *merge_ordering1,
...
@@ -127,7 +128,7 @@ equal_merge_ordering(MergeOrder *merge_ordering1,
* Returns true iff the sort operators are in the same order.
* Returns true iff the sort operators are in the same order.
*/
*/
static
bool
static
bool
equal_sortops_order
(
Oid
*
ordering1
,
Oid
*
ordering2
,
int
*
better_sort
)
sortops_order_match
(
Oid
*
ordering1
,
Oid
*
ordering2
,
int
*
better_sort
)
{
{
int
i
=
0
;
int
i
=
0
;
...
@@ -160,7 +161,7 @@ equal_sortops_order(Oid *ordering1, Oid *ordering2, int *better_sort)
...
@@ -160,7 +161,7 @@ equal_sortops_order(Oid *ordering1, Oid *ordering2, int *better_sort)
*
better_sort
=
1
;
*
better_sort
=
1
;
return
true
;
return
true
;
}
}
if
(
ordering1
[
i
]
==
0
&&
ordering2
[
i
]
!=
0
)
if
(
ordering1
[
i
]
==
0
&&
ordering2
[
i
]
!=
0
)
{
{
*
better_sort
=
2
;
*
better_sort
=
2
;
...
...
src/backend/optimizer/util/pathnode.c
View file @
34ecb9d8
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.3
0 1999/02/11 17:21:51
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.3
1 1999/02/11 21:05:28
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#include "parser/parsetree.h"
/* for getrelid() */
#include "parser/parsetree.h"
/* for getrelid() */
static
Path
*
better_path
(
Path
*
new_path
,
List
*
unique_paths
,
bool
*
is
N
ew
);
static
Path
*
better_path
(
Path
*
new_path
,
List
*
unique_paths
,
bool
*
is
_n
ew
);
/*****************************************************************************
/*****************************************************************************
...
@@ -173,11 +173,14 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
...
@@ -173,11 +173,14 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
printf
(
"newpath
\n
"
);
printf
(
"newpath
\n
"
);
pprint
(
new_path
->
pathkeys
);
pprint
(
new_path
->
pathkeys
);
if
(
path
->
pathkeys
&&
new_path
->
pathkeys
&&
if
(
path
->
pathkeys
&&
new_path
->
pathkeys
&&
length
(
lfirst
(
path
->
pathkeys
))
>=
2
&&
length
(
lfirst
(
path
->
pathkeys
))
>=
2
/* &&
length
(
lfirst
(
path
->
pathkeys
))
<
length
(
lfirst
(
new_path
->
pathkeys
)))
length(lfirst(path->pathkeys)) <
length(lfirst(new_path->pathkeys))*/
)
sleep
(
0
);
/* set breakpoint here */
sleep
(
0
);
/* set breakpoint here */
}
}
if
(
!
pathorder_match
(
new_path
->
pathorder
,
path
->
pathorder
,
&
better_sort
))
if
(
!
pathorder_match
(
new_path
->
pathorder
,
path
->
pathorder
,
&
better_sort
)
||
better_sort
!=
0
)
{
{
printf
(
"oldord
\n
"
);
printf
(
"oldord
\n
"
);
pprint
(
path
->
pathorder
);
pprint
(
path
->
pathorder
);
...
@@ -186,43 +189,43 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
...
@@ -186,43 +189,43 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
}
}
#endif
#endif
if
(
pathkeys_match
(
new_path
->
pathkeys
,
path
->
pathkeys
,
&
better_key
))
if
(
pathkeys_match
(
new_path
->
pathkeys
,
path
->
pathkeys
,
&
better_key
)
&&
pathorder_match
(
new_path
->
pathorder
,
path
->
pathorder
,
&
better_sort
))
{
{
if
(
pathorder_match
(
new_path
->
pathorder
,
path
->
pathorder
,
&
better_sort
))
/*
* Replace pathkeys that match exactly, (1,2), (1,2).
* Replace pathkeys (1,2) with (1,2,3) if the latter is not
* more expensive and replace unordered path with ordered
* path if it is not more expensive. Favor sorted keys
* over unsorted keys in the same way.
*/
/* same keys, and new is cheaper, use it */
if
((
better_key
==
0
&&
better_sort
==
0
&&
new_path
->
path_cost
<
path
->
path_cost
)
||
/* new is better, and cheaper, use it */
(((
better_key
==
1
&&
better_sort
!=
2
)
||
(
better_key
!=
2
&&
better_sort
==
1
))
&&
new_path
->
path_cost
<=
path
->
path_cost
))
{
{
/*
*
is_new
=
false
;
* Replace pathkeys that match exactly, (1,2), (1,2).
return
new_path
;
* Replace pathkeys (1,2) with (1,2,3) if the latter is not
}
* more expensive and replace unordered path with ordered
* path if it is not more expensive. Favor sorted keys
/* same keys, new is more expensive, stop */
* over unsorted keys in the same way.
else
if
*/
((
better_key
==
0
&&
better_sort
==
0
&&
/* same keys, and new is cheaper, use it */
new_path
->
path_cost
>=
path
->
path_cost
)
||
if
((
better_key
==
0
&&
better_sort
==
0
&&
new_path
->
path_cost
<
path
->
path_cost
)
||
/* old is better, and less expensive, stop */
(((
better_key
==
2
&&
better_sort
!=
1
)
||
/* new is better, and cheaper, use it */
(
better_key
!=
1
&&
better_sort
==
2
))
&&
(((
better_key
==
1
&&
better_sort
!=
2
)
||
new_path
->
path_cost
>=
path
->
path_cost
))
(
better_key
!=
2
&&
better_sort
==
1
))
&&
{
new_path
->
path_cost
<=
path
->
path_cost
))
*
is_new
=
false
;
{
return
NULL
;
*
is_new
=
false
;
return
new_path
;
}
/* same keys, new is more expensive, stop */
else
if
((
better_key
==
0
&&
better_sort
==
0
&&
new_path
->
path_cost
>=
path
->
path_cost
)
||
/* old is better, and less expensive, stop */
(((
better_key
==
2
&&
better_sort
!=
1
)
||
(
better_key
!=
1
&&
better_sort
==
2
))
&&
new_path
->
path_cost
>=
path
->
path_cost
))
{
*
is_new
=
false
;
return
NULL
;
}
}
}
}
}
}
}
...
...
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