pgsql: Emit null-keyed hash join outer tuples immediately when feasible

Started by Tom Lane30 days ago1 messagescommitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

Emit null-keyed hash join outer tuples immediately when feasible.

Commit 1811f1af9 put outer tuples with null join keys into a
tuplestore and emitted them at the end of the batch, which risks
expensive spills to disk if there are a lot of them. It's difficult
to avoid the tuplestore in a multi-batch parallel join. But in the
non-parallel and single-batch cases we can just emit such tuples
immediately, at the tiny cost of propagating the "is-null" result
flag one call level further up. This avoids a performance regression
from v18 for such cases.

Author: shihao zhong <zhong950419@gmail.com>
Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: /messages/by-id/CAGRkXqTgugmYrtnP_11NjL_GCXwAfzVfm5WKUNFsfZOzxDF2rA@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/126976a8ffcfa47f40d3df09243ebf4606001912

Modified Files
--------------
src/backend/executor/nodeHashjoin.c | 62 +++++++++++++++++++++++--------------
src/include/executor/hashjoin.h | 11 ++++---
src/include/nodes/execnodes.h | 3 +-
3 files changed, 47 insertions(+), 29 deletions(-)