Re: [PG19] Hash join writes null-keyed outer rows to temp files

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PG19] Hash join writes null-keyed outer rows to temp files
Date: 2026-10-22 19:23:17
Message-ID: 2769765.1792696997@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

shihao zhong <zhong950419(at)gmail(dot)com> writes:
> The original mail said returning them right away would need a big
> rewrite [1]. The patch gives such a row a dummy hash value of 0 and
> lets it probe as usual. That value always maps to the current batch,
> and the row cannot match, so it comes out null-extended right away,
> like in 18.

I do not think I believe this patch. In particular, it assumes that
hashvalue 0 will map to the current batch, which is only accidentally
true for ExecHashGetBucketAndBatch (but okay, we could add a provision
to its API that hashvalue 0 must map to batch 0) and more importantly
can fail entirely for ExecHashGetSkewBucket. There's no reason to
assume there couldn't be a real tuple with hashvalue 0, and if there
were one already in the skew table then the wrong things would happen.

Also, trading off storing to a tuplestore for scanning a hash bucket
is not obviously a win.

> Another way is to return such a row with a flag and jump straight to
> HJ_FILL_OUTER_TUPLE, skipping the probe.

I like this idea substantially better. More or less as attached?

regards, tom lane

Attachment Content-Type Size
v2-emit-null-keyed-outer-hash-join-tuples-immediately.patch text/x-diff 7.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2026-10-22 19:30:41 Re: Parallel vacuum: workers together with leader could overrun cost budget
Previous Message Gabriele Bartolini 2026-10-22 19:15:12 Re: Switching XLog source from archive to streaming when primary available