Pack tuples in a hash join batch densely, to save memory

Enterprise / PostgreSQL - Heikki Linnakangas [iki.fi] - 10 September 2014 13:24 UTC

Instead of palloc'ing each HashJoinTuple individually, allocate 32kB chunks and pack the tuples densely in the chunks. This avoids the AllocChunk header overhead, and the space wasted by standard allocator's habit of rounding sizes up to the nearest power of two.

This doesn't contain any planner changes, because the planner's estimate of memory usage ignores the palloc overhead. Now that the overhead is smaller, the planner's estimates are in fact more accurate.

Tomas Vondra, reviewed by Robert Haas.

45f6240 Pack tuples in a hash join batch densely, to save memory.
src/backend/executor/nodeHash.c | 151 +++++++++++++++++++++++++++++++--------
src/include/executor/hashjoin.h | 22 ++++++
2 files changed, 145 insertions(+), 28 deletions(-)

Upstream: git.postgresql.org


  • Share