Skip to content

Commit fecb2b0

Browse files
committed
Minor code cleanup in optimizer.
1 parent f2ed835 commit fecb2b0

File tree

3 files changed

+16
-29
lines changed

3 files changed

+16
-29
lines changed

src/backend/optimizer/path/clausesel.c

Lines changed: 3 additions & 3 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/clausesel.c,v 1.18 1999/02/15 01:06:57 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.19 1999/05/16 19:45:37 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -53,7 +53,7 @@ set_clause_selectivities(List *restrictinfo_list, Cost new_selectivity)
5353
{
5454
clausenode = (RestrictInfo *) lfirst(temp);
5555
cost_clause = clausenode->selectivity;
56-
if (FLOAT_IS_ZERO(cost_clause) || new_selectivity < cost_clause)
56+
if (cost_clause <= 0 || new_selectivity < cost_clause)
5757
clausenode->selectivity = new_selectivity;
5858
}
5959
}
@@ -129,7 +129,7 @@ set_rest_selec(Query *root, List *restrictinfo_list)
129129
* Check to see if the selectivity of this clause or any 'or'
130130
* subclauses (if any) haven't been set yet.
131131
*/
132-
if (valid_or_clause(clausenode) || FLOAT_IS_ZERO(cost_clause))
132+
if (cost_clause <= 0 || valid_or_clause(clausenode))
133133
{
134134
clausenode->selectivity = compute_clause_selec(root,
135135
(Node *) clausenode->clause,

src/backend/optimizer/path/joinpath.c

Lines changed: 10 additions & 18 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/joinpath.c,v 1.34 1999/05/01 19:47:42 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.35 1999/05/16 19:45:37 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -418,29 +418,21 @@ match_unsorted_inner(RelOptInfo *joinrel,
418418
List *innerpath_list,
419419
List *mergeinfo_list)
420420
{
421-
Path *innerpath = (Path *) NULL;
422421
List *mp_list = NIL;
423-
PathOrder *innerpath_ordering = NULL;
424-
Cost temp1 = 0.0;
425-
bool temp2 = false;
426-
List *i = NIL;
422+
List *i;
427423

428424
foreach(i, innerpath_list)
429425
{
426+
Path *innerpath = (Path *) lfirst(i);
427+
PathOrder *innerpath_ordering = innerpath->pathorder;
430428
MergeInfo *xmergeinfo = (MergeInfo *) NULL;
431429
List *clauses = NIL;
432430
List *matchedJoinKeys = NIL;
433431
List *matchedJoinClauses = NIL;
434432

435-
innerpath = (Path *) lfirst(i);
436-
437-
innerpath_ordering = innerpath->pathorder;
438-
439433
if (innerpath_ordering)
440-
{
441434
xmergeinfo = match_order_mergeinfo(innerpath_ordering,
442-
mergeinfo_list);
443-
}
435+
mergeinfo_list);
444436

445437
if (xmergeinfo)
446438
clauses = ((JoinMethod *) xmergeinfo)->clauses;
@@ -463,13 +455,13 @@ match_unsorted_inner(RelOptInfo *joinrel,
463455
*/
464456
if (clauses && matchedJoinKeys)
465457
{
458+
Cost temp1;
459+
466460
temp1 = outerrel->cheapestpath->path_cost +
467461
cost_sort(matchedJoinKeys, outerrel->size, outerrel->width);
468462

469-
temp2 = (bool) (FLOAT_IS_ZERO(innerpath->outerjoincost)
470-
|| (innerpath->outerjoincost > temp1));
471-
472-
if (temp2)
463+
if (innerpath->outerjoincost <= 0 /* unset? */
464+
|| innerpath->outerjoincost > temp1)
473465
{
474466
List *outerkeys = make_pathkeys_from_joinkeys(matchedJoinKeys,
475467
outerrel->targetlist,
@@ -494,8 +486,8 @@ match_unsorted_inner(RelOptInfo *joinrel,
494486
}
495487
}
496488
}
497-
return mp_list;
498489

490+
return mp_list;
499491
}
500492

501493
static bool

src/include/optimizer/internal.h

Lines changed: 3 additions & 8 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: internal.h,v 1.18 1999/03/07 12:00:38 momjian Exp $
9+
* $Id: internal.h,v 1.19 1999/05/16 19:45:36 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -27,7 +27,7 @@
2727
* System-dependent tuning constants
2828
*
2929
*/
30-
#define _CPU_PAGE_WEIGHT_ 0.033/* CPU-heap-to-page cost weighting factor */
30+
#define _CPU_PAGE_WEIGHT_ 0.033 /* CPU-heap-to-page cost weighting factor */
3131
#define _CPU_INDEX_PAGE_WEIGHT_ 0.017 /* CPU-index-to-page cost
3232
* weighting factor */
3333
#define _MAX_KEYS_ INDEX_MAX_KEYS /* maximum number of keys in an
@@ -64,7 +64,7 @@
6464
/* Identifier for invalid relation OIDs and attribute numbers for use by
6565
* selectivity functions
6666
*/
67-
#define _SELEC_VALUE_UNKNOWN_ -1
67+
#define _SELEC_VALUE_UNKNOWN_ (-1)
6868

6969
/* Flag indicating that a clause constant is really a parameter (or other
7070
* non-constant?), a non-parameter, or a constant on the right side
@@ -75,11 +75,6 @@
7575
#define _SELEC_CONSTANT_LEFT_ 0
7676
#define _SELEC_CONSTANT_RIGHT_ 2
7777

78-
#define TOLERANCE 0.000001
79-
80-
#define FLOAT_EQUAL(X,Y) ((X) - (Y) < TOLERANCE)
81-
#define FLOAT_IS_ZERO(X) (FLOAT_EQUAL(X,0.0))
82-
8378
/* #define deactivate_joininfo(joininfo) joininfo->inactive=true*/
8479
/*#define joininfo_inactive(joininfo) joininfo->inactive */
8580

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy