agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Tomas Vondra <[email protected]>
Subject: [PATCH 3/5] rework add_partial_path_precheck - check costs first
Date: Fri, 3 Apr 2020 18:43:50 +0200

---
 src/backend/optimizer/util/pathnode.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
index 7211fc35fd..4e798b801a 100644
--- a/src/backend/optimizer/util/pathnode.c
+++ b/src/backend/optimizer/util/pathnode.c
@@ -880,18 +880,25 @@ add_partial_path_precheck(RelOptInfo *parent_rel, Cost startup_cost,
 	{
 		Path	   *old_path = (Path *) lfirst(p1);
 		PathKeysComparison keyscmp;
+		bool		compared = false;
 
-		keyscmp = compare_pathkeys(pathkeys, old_path->pathkeys);
-		if (keyscmp != PATHKEYS_DIFFERENT)
+		if ((startup_cost > old_path->startup_cost * STD_FUZZ_FACTOR) &&
+			(total_cost > old_path->total_cost * STD_FUZZ_FACTOR))
 		{
-			if ((startup_cost > old_path->startup_cost * STD_FUZZ_FACTOR) &&
-				(total_cost > old_path->total_cost * STD_FUZZ_FACTOR) &&
-				(keyscmp != PATHKEYS_BETTER1))
+			keyscmp = compare_pathkeys(pathkeys, old_path->pathkeys);
+			compared = true;
+
+			if (keyscmp != PATHKEYS_BETTER1)
 				return false;
+		}
+
+		if ((old_path->startup_cost > startup_cost * STD_FUZZ_FACTOR) &&
+			(old_path->total_cost > total_cost * STD_FUZZ_FACTOR))
+		{
+			if (!compared)
+				keyscmp = compare_pathkeys(pathkeys, old_path->pathkeys);
 
-			if ((old_path->startup_cost > startup_cost * STD_FUZZ_FACTOR) &&
-				(old_path->total_cost > total_cost * STD_FUZZ_FACTOR) &&
-				(keyscmp != PATHKEYS_BETTER2))
+			if (keyscmp != PATHKEYS_BETTER2)
 				return true;
 		}
 	}
-- 
2.21.1


--mhm2o3dzmb5lomaa--





view thread (3+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH 3/5] rework add_partial_path_precheck - check costs first
  In-Reply-To: <no-message-id-194785@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox