From 129543e22d6ee79038ad91f649accf9856686d23 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Thu, 11 Feb 1999 05:29:08 +0000
Subject: [PATCH] optimizer cleanup

---
 src/backend/optimizer/path/joinutils.c |  5 ++---
 src/backend/optimizer/util/pathnode.c  | 13 +++++++++----
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/backend/optimizer/path/joinutils.c b/src/backend/optimizer/path/joinutils.c
index 4292bc4af24..d57d0d6d13a 100644
--- a/src/backend/optimizer/path/joinutils.c
+++ b/src/backend/optimizer/path/joinutils.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.16 1999/02/10 21:02:39 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.17 1999/02/11 05:29:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -373,8 +373,7 @@ new_join_pathkey(List *subkeys,
 		if (tlist_key)
 		{
 			if (!member(tlist_key, matched_subkeys))
-				newly_considered_subkeys = lcons(tlist_key,
-												 matched_subkeys);
+				newly_considered_subkeys = lcons(tlist_key, matched_subkeys);
 		}
 		else
 			newly_considered_subkeys = matched_subkeys;
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
index 02360d74f08..28ab4573741 100644
--- a/src/backend/optimizer/util/pathnode.c
+++ b/src/backend/optimizer/util/pathnode.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.24 1999/02/11 04:08:43 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.25 1999/02/11 05:29:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -195,14 +195,19 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
 				 * more expensive and replace unordered path with ordered
 				 * path if it is not more expensive.
 				 */
+				 
+					/* same keys, and new is cheaper, use it */
 			    if ((longer_key == 0 && new_path->path_cost <  path->path_cost) ||
-					(longer_key == 1 && new_path->path_cost <= path->path_cost) ||
-					(longer_key == 2 && new_path->path_cost >= path->path_cost))
+					/* new is longer, and cheaper, use it */
+					(longer_key == 1 && new_path->path_cost <= path->path_cost))
 				{
 					*is_new = false;
 					return new_path;
 				}
-				else
+						/* 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))
 				{
 					*is_new = false;
 					return NULL;
-- 
GitLab