Minor code cleanup in optimizer.
authorTom Lane
Sun, 16 May 1999 19:45:37 +0000 (19:45 +0000)
committerTom Lane
Sun, 16 May 1999 19:45:37 +0000 (19:45 +0000)
src/backend/optimizer/path/clausesel.c
src/backend/optimizer/path/joinpath.c
src/include/optimizer/internal.h

index 18bb69f53c9e25134010161e993c7252ba575e3e..1eeae4c6d3d134f8d24888512340676497aaa7cb 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.18 1999/02/15 01:06:57 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.19 1999/05/16 19:45:37 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,7 +53,7 @@ set_clause_selectivities(List *restrictinfo_list, Cost new_selectivity)
    {
        clausenode = (RestrictInfo *) lfirst(temp);
        cost_clause = clausenode->selectivity;
-       if (FLOAT_IS_ZERO(cost_clause) || new_selectivity < cost_clause)
+       if (cost_clause <= 0 || new_selectivity < cost_clause)
            clausenode->selectivity = new_selectivity;
    }
 }
@@ -129,7 +129,7 @@ set_rest_selec(Query *root, List *restrictinfo_list)
         * Check to see if the selectivity of this clause or any 'or'
         * subclauses (if any) haven't been set yet.
         */
-       if (valid_or_clause(clausenode) || FLOAT_IS_ZERO(cost_clause))
+       if (cost_clause <= 0 || valid_or_clause(clausenode))
        {
            clausenode->selectivity = compute_clause_selec(root,
                                     (Node *) clausenode->clause,
index 8b2f5139ecdfafdb8a1ae4196e67364cda8e4f31..930112f888e4b12566b676df1c003f479f94c37a 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.34 1999/05/01 19:47:42 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.35 1999/05/16 19:45:37 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -418,29 +418,21 @@ match_unsorted_inner(RelOptInfo *joinrel,
                     List *innerpath_list,
                     List *mergeinfo_list)
 {
-   Path       *innerpath = (Path *) NULL;
    List       *mp_list = NIL;
-   PathOrder  *innerpath_ordering = NULL;
-   Cost        temp1 = 0.0;
-   bool        temp2 = false;
-   List       *i = NIL;
+   List       *i;
 
    foreach(i, innerpath_list)
    {
+       Path       *innerpath = (Path *) lfirst(i);
+       PathOrder  *innerpath_ordering = innerpath->pathorder;
        MergeInfo  *xmergeinfo = (MergeInfo *) NULL;
        List       *clauses = NIL;
        List       *matchedJoinKeys = NIL;
        List       *matchedJoinClauses = NIL;
 
-       innerpath = (Path *) lfirst(i);
-
-       innerpath_ordering = innerpath->pathorder;
-
        if (innerpath_ordering)
-       {
            xmergeinfo = match_order_mergeinfo(innerpath_ordering,
-                                     mergeinfo_list);
-       }
+                                              mergeinfo_list);
 
        if (xmergeinfo)
            clauses = ((JoinMethod *) xmergeinfo)->clauses;
@@ -463,13 +455,13 @@ match_unsorted_inner(RelOptInfo *joinrel,
         */
        if (clauses && matchedJoinKeys)
        {
+           Cost        temp1;
+
            temp1 = outerrel->cheapestpath->path_cost +
                cost_sort(matchedJoinKeys, outerrel->size, outerrel->width);
 
-           temp2 = (bool) (FLOAT_IS_ZERO(innerpath->outerjoincost)
-                           || (innerpath->outerjoincost > temp1));
-
-           if (temp2)
+           if (innerpath->outerjoincost <= 0 /* unset? */
+               || innerpath->outerjoincost > temp1)
            {
                List       *outerkeys = make_pathkeys_from_joinkeys(matchedJoinKeys,
                                  outerrel->targetlist,
@@ -494,8 +486,8 @@ match_unsorted_inner(RelOptInfo *joinrel,
            }
        }
    }
-   return mp_list;
 
+   return mp_list;
 }
 
 static bool
index 24eb5327cb00e2db97ecb46bbfea13df42a7189c..0241a3f98f101edd18ea5fc3825229082e17aeb1 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: internal.h,v 1.18 1999/03/07 12:00:38 momjian Exp $
+ * $Id: internal.h,v 1.19 1999/05/16 19:45:36 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,7 +27,7 @@
  *     System-dependent tuning constants
  *
  */
-#define _CPU_PAGE_WEIGHT_  0.033/* CPU-heap-to-page cost weighting factor */
+#define _CPU_PAGE_WEIGHT_  0.033  /* CPU-heap-to-page cost weighting factor */
 #define _CPU_INDEX_PAGE_WEIGHT_ 0.017  /* CPU-index-to-page cost
                                         * weighting factor */
 #define _MAX_KEYS_    INDEX_MAX_KEYS   /* maximum number of keys in an
@@ -64,7 +64,7 @@
 /*    Identifier for invalid relation OIDs and attribute numbers for use by
  *    selectivity functions
  */
-#define _SELEC_VALUE_UNKNOWN_  -1
+#define _SELEC_VALUE_UNKNOWN_  (-1)
 
 /*    Flag indicating that a clause constant is really a parameter (or other
  *     non-constant?), a non-parameter, or a constant on the right side
 #define _SELEC_CONSTANT_LEFT_  0
 #define _SELEC_CONSTANT_RIGHT_ 2
 
-#define TOLERANCE 0.000001
-
-#define FLOAT_EQUAL(X,Y) ((X) - (Y) < TOLERANCE)
-#define FLOAT_IS_ZERO(X) (FLOAT_EQUAL(X,0.0))
-
 /* #define deactivate_joininfo(joininfo)       joininfo->inactive=true*/
 /*#define joininfo_inactive(joininfo)  joininfo->inactive */