]> granicus.if.org Git - postgresql/commit
ExecHashRemoveNextSkewBucket must physically copy tuples to main hashtable.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 7 Feb 2016 17:29:17 +0000 (12:29 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 7 Feb 2016 17:29:17 +0000 (12:29 -0500)
commit129db3cbee704e71cff9f90f62691488c8ef768d
tree0b95878b4088d81bdd3b4cf4bc99d9572546b0f3
parent2b94b5ef8df1b037307634f8d0f881e2651d654e
ExecHashRemoveNextSkewBucket must physically copy tuples to main hashtable.

Commit 45f6240a8fa9d355 added an assumption in ExecHashIncreaseNumBatches
and ExecHashIncreaseNumBuckets that they could find all tuples in the main
hash table by iterating over the "dense storage" introduced by that patch.
However, ExecHashRemoveNextSkewBucket continued its old practice of simply
re-linking deleted skew tuples into the main table's hashchains.  Hence,
such tuples got lost during any subsequent increase in nbatch or nbuckets,
and would never get joined, as reported in bug #13908 from Seth P.

I (tgl) think that the aforesaid commit has got multiple design issues
and should be reworked rather completely; but there is no time for that
right now, so band-aid the problem by making ExecHashRemoveNextSkewBucket
physically copy deleted skew tuples into the "dense storage" arena.

The added test case is able to exhibit the problem by means of fooling the
planner with a WHERE condition that it will underestimate the selectivity
of, causing the initial nbatch estimate to be too small.

Tomas Vondra and Tom Lane.  Thanks to David Johnston for initial
investigation into the bug report.
src/backend/executor/nodeHash.c
src/test/regress/expected/join.out
src/test/regress/sql/join.sql