Revise generation of hashjoin paths: generate one path per
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 6 Aug 1999 04:00:17 +0000 (04:00 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 6 Aug 1999 04:00:17 +0000 (04:00 +0000)
commite1fad50a5d362d78b9f571b71b372faaa597462a
treefb7953f8d6bb903be4d1ee6e4c3ddc3a9ea4ad26
parentb7883d7e3a1d7d3d98b2bd8186ddf60011d45bdd
Revise generation of hashjoin paths: generate one path per
hashjoinable clause, not one path for a randomly-chosen element of each
set of clauses with the same join operator.  That is, if you wrote
   SELECT ... WHERE t1.f1 = t2.f2 and t1.f3 = t2.f4,
and both '=' ops were the same opcode (say, all four fields are int4),
then the system would either consider hashing on f1=f2 or on f3=f4,
but it would *not* consider both possibilities.  Boo hiss.
Also, revise estimation of hashjoin costs to include a penalty when the
inner join var has a high disbursion --- ie, the most common value is
pretty common.  This tends to lead to badly skewed hash bucket occupancy
and way more comparisons than you'd expect on average.
I imagine that the cost calculation still needs tweaking, but at least
it generates a more reasonable plan than before on George Young's example.
src/backend/optimizer/path/costsize.c
src/backend/optimizer/path/joinpath.c
src/backend/optimizer/util/pathnode.c
src/include/optimizer/cost.h
src/include/optimizer/pathnode.h