|
42 | 42 | * Portions Copyright (c) 1994, Regents of the University of California
|
43 | 43 | *
|
44 | 44 | * IDENTIFICATION
|
45 |
| - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.57 2000/04/12 17:15:19 momjian Exp $ |
| 45 | + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.58 2000/04/18 05:43:02 tgl Exp $ |
46 | 46 | *
|
47 | 47 | *-------------------------------------------------------------------------
|
48 | 48 | */
|
|
51 | 51 |
|
52 | 52 | #include <math.h>
|
53 | 53 |
|
| 54 | +#include "executor/nodeHash.h" |
54 | 55 | #include "miscadmin.h"
|
55 | 56 | #include "nodes/plannodes.h"
|
56 | 57 | #include "optimizer/clauses.h"
|
@@ -604,12 +605,17 @@ cost_hashjoin(Path *path,
|
604 | 605 | run_cost += cpu_operator_cost * outer_path->parent->rows;
|
605 | 606 |
|
606 | 607 | /*
|
607 |
| - * the number of tuple comparisons needed is the number of outer |
608 |
| - * tuples times the typical hash bucket size, which we estimate |
609 |
| - * conservatively as the inner disbursion times the inner tuple count. |
| 608 | + * The number of tuple comparisons needed is the number of outer |
| 609 | + * tuples times the typical hash bucket size. nodeHash.c tries for |
| 610 | + * average bucket loading of NTUP_PER_BUCKET, but that goal will |
| 611 | + * be reached only if data values are uniformly distributed among |
| 612 | + * the buckets. To be conservative, we scale up the target bucket |
| 613 | + * size by the number of inner rows times inner disbursion, giving |
| 614 | + * an estimate of the typical number of duplicates of each value. |
| 615 | + * We then charge one cpu_operator_cost per tuple comparison. |
610 | 616 | */
|
611 | 617 | run_cost += cpu_operator_cost * outer_path->parent->rows *
|
612 |
| - ceil(inner_path->parent->rows * innerdisbursion); |
| 618 | + NTUP_PER_BUCKET * ceil(inner_path->parent->rows * innerdisbursion); |
613 | 619 |
|
614 | 620 | /*
|
615 | 621 | * Estimate the number of tuples that get through the hashing filter
|
|
0 commit comments