diff options
Diffstat (limited to 'src/backend/optimizer/util/pathnode.c')
-rw-r--r-- | src/backend/optimizer/util/pathnode.c | 55 |
1 files changed, 18 insertions, 37 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 2f10fbe1939..8f55c2d98f1 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.111.4.1 2005/07/15 17:09:49 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.111.4.2 2005/07/22 19:12:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -98,60 +98,41 @@ compare_path_costs(Path *path1, Path *path2, CostSelector criterion) 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). + * We use a fuzz factor of 1% of the smaller cost. * * 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 (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 (Abs(path1->total_cost - path2->total_cost) > fuzz) - { - if (path1->total_cost < path2->total_cost) - return -1; - else - return +1; - } + if (path1->total_cost > path2->total_cost * 1.01) + return +1; + if (path2->total_cost > path1->total_cost * 1.01) + 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 (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 (Abs(path1->startup_cost - path2->startup_cost) > fuzz) - { - if (path1->startup_cost < path2->startup_cost) - return -1; - else - return +1; - } + if (path1->startup_cost > path2->startup_cost * 1.01) + return +1; + if (path2->startup_cost > path1->startup_cost * 1.01) + return -1; } return 0; } |