Re: [PATCH] Resolve Parallel Hash Join Performance Issue
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: "Deng, Gang" <gang.deng@intel.com>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2020-01-21T05:20:11Z
Lists: pgsql-hackers
Attachments
- 0001-Avoid-unnecessary-shmem-writes-in-Parallel-Hash-Join.patch (application/octet-stream) patch 0001
(Replies to both Gang and Tom below). On Fri, Jan 10, 2020 at 1:52 PM Deng, Gang <gang.deng@intel.com> wrote: > Thank you for the comment. Yes, I agree the alternative of using '(!parallel)', so that no need to test the bit. Will someone submit patch to for it accordingly? Here's a patch like that. On Fri, Jan 10, 2020 at 3:43 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > Thomas Munro <thomas.munro@gmail.com> writes: > > Right, I see. The funny thing is that the match bit is not even used > > in this query (it's used for right and full hash join, and those > > aren't supported for parallel joins yet). Hmm. So, instead of the > > test you proposed, an alternative would be to use if (!parallel). > > That's a value that will be constant-folded, so that there will be no > > branch in the generated code (see the pg_attribute_always_inline > > trick). If, in a future release, we need the match bit for parallel > > hash join because we add parallel right/full hash join support, we > > could do it the way you showed, but only if it's one of those join > > types, using another constant parameter. > > Can we base the test off the match type today, and avoid leaving > something that will need to be fixed later? I agree that it'd be nicer to use the logically correct thing, namely a test of HJ_FILL_INNER(node), but that'd be a run-time check. I'd like to back-patch this and figured that we don't want to add new branches too casually. I have an experimental patch where "fill_inner" and "fill_outer" are compile-time constants and you can skip various bits of code without branching (part of a larger experiment to figure out which of many parameters are worth specialising at a cost of a couple of KB of text per combination, including the ability to use wider hashes so that monster sized joins work better). Then I could test the logically correct thing explicitly without branches.
Commits
-
Avoid unnecessary shm writes in Parallel Hash Join.
- 3e4818e9dd5b 13.0 landed
- 6a9fc75d0391 11.7 landed
- f9d0be241aac 12.2 landed