pgsql: ExecHashRemoveNextSkewBucket must physically copy tuples to main - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: ExecHashRemoveNextSkewBucket must physically copy tuples to main
Date
Msg-id E1aST9e-0000IB-LE@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/f867ce5518202a4e625dc41b7036fec47ee0e09e

Modified Files
--------------
src/backend/executor/nodeHash.c    | 15 +++++++++++++--
src/test/regress/expected/join.out | 28 ++++++++++++++++++++++++++++
src/test/regress/sql/join.sql      | 16 ++++++++++++++++
3 files changed, 57 insertions(+), 2 deletions(-)


pgsql-committers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: pgsql: Add gin_clean_pending_list function to clean up GIN pending list
Next
From: Tom Lane
Date:
Subject: pgsql: ExecHashRemoveNextSkewBucket must physically copy tuples to main