*** src/backend/optimizer/util/pathnode.c.orig	Fri Jul 15 13:09:25 2005
--- src/backend/optimizer/util/pathnode.c	Fri Jul 22 12:08:25 2005
***************
*** 98,157 ****
  static int
  compare_fuzzy_path_costs(Path *path1, Path *path2, CostSelector criterion)
  {
- 	Cost		fuzz;
- 
  	/*
! 	 * The fuzz factor is set at one percent of the smaller total_cost,
! 	 * but not less than 0.01 cost units (just in case total cost is
! 	 * zero).
  	 *
  	 * XXX does this percentage need to be user-configurable?
  	 */
- 	fuzz = Min(path1->total_cost, path2->total_cost) * 0.01;
- 	fuzz = Max(fuzz, 0.01);
- 
  	if (criterion == STARTUP_COST)
  	{
! 		if (Abs(path1->startup_cost - path2->startup_cost) > fuzz)
! 		{
! 			if (path1->startup_cost < path2->startup_cost)
! 				return -1;
! 			else
! 				return +1;
! 		}
  
  		/*
  		 * If paths have the same startup cost (not at all unlikely),
  		 * order them by total cost.
  		 */
! 		if (Abs(path1->total_cost - path2->total_cost) > fuzz)
! 		{
! 			if (path1->total_cost < path2->total_cost)
! 				return -1;
! 			else
! 				return +1;
! 		}
  	}
  	else
  	{
! 		if (Abs(path1->total_cost - path2->total_cost) > fuzz)
! 		{
! 			if (path1->total_cost < path2->total_cost)
! 				return -1;
! 			else
! 				return +1;
! 		}
  
  		/*
  		 * If paths have the same total cost, order them by startup cost.
  		 */
! 		if (Abs(path1->startup_cost - path2->startup_cost) > fuzz)
! 		{
! 			if (path1->startup_cost < path2->startup_cost)
! 				return -1;
! 			else
! 				return +1;
! 		}
  	}
  	return 0;
  }
--- 98,138 ----
  static int
  compare_fuzzy_path_costs(Path *path1, Path *path2, CostSelector criterion)
  {
  	/*
! 	 * We use a fuzz factor of 1% of the smaller cost.
  	 *
  	 * XXX does this percentage need to be user-configurable?
  	 */
  	if (criterion == STARTUP_COST)
  	{
! 		if (path1->startup_cost > path2->startup_cost * 1.01)
! 			return +1;
! 		if (path2->startup_cost > path1->startup_cost * 1.01)
! 			return -1;
  
  		/*
  		 * If paths have the same startup cost (not at all unlikely),
  		 * order them by total cost.
  		 */
! 		if (path1->total_cost > path2->total_cost * 1.01)
! 			return +1;
! 		if (path2->total_cost > path1->total_cost * 1.01)
! 			return -1;
  	}
  	else
  	{
! 		if (path1->total_cost > path2->total_cost * 1.01)
! 			return +1;
! 		if (path2->total_cost > path1->total_cost * 1.01)
! 			return -1;
  
  		/*
  		 * If paths have the same total cost, order them by startup cost.
  		 */
! 		if (path1->startup_cost > path2->startup_cost * 1.01)
! 			return +1;
! 		if (path2->startup_cost > path1->startup_cost * 1.01)
! 			return -1;
  	}
  	return 0;
  }
