]> 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:32 +0000 (12:29 -0500)
commitf867ce5518202a4e625dc41b7036fec47ee0e09e
treef8037946270665ccd4222d3810c3fa402526cf93
parentd89f06f0482458d4b76e3be67ea428fec2a0aeb6
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