although that's not oriented specifically to performance issues.
(I recall that we have fixed some problems in the past that could lead to unreasonable numbers of temp files in hash joins. Whether there's more to do, or Peter is running a version that lacks those fixes, is impossible to tell with the given info.)
Thanks.
I'll add that given the nature of the problem that changing temp_file_limit away from its default of unlimited may be useful.