Parallell hashjoin sometimes ignores temp_tablespaces

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Parallell hashjoin sometimes ignores temp_tablespaces
Date: 2020-06-29 15:02:43
Message-ID: CABUevExg5YEsOvqMxrjoNvb3ApVyH+9jggWGKwTDFyFCVWczGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

If a database (a) has a default tablespace set,

Reproduction:

CREATE TABLESPACE t LOCATION '/tmp/t';
CREATE DATABASE dumb TABLESPACE t;
\c dumb
SET temp_tablespaces=t;

At this point if you run a query with a parallel hash join in it, the
tempfiles go in base/pgsql_tmp instead of the temporary tablespace. For
example:

create table foo(bar int);
insert into foo select * from generate_series(1,1000000);
set parallel_tuple_cost =0;
set parallel_setup_cost =0;
set log_temp_files=0;
set client_min_messages ='log';
explain analyze select foo.bar,count(*) from foo inner join foo foo2 on
foo.bar=foo2.bar group by foo.bar;

Will trigger some temp files in the 't' tablespace and some in the
'pg_default' one.

I think the fix is the attached one (tested on version 11 which is what
$customer is using). To me it looks like this may have been a copy/paste
error all the way back in 98e8b480532 which added default_tablespace back
in 2004. (And is in itself entirely unrelated to parallel hashjoin, but
that's where it got exposed at least in my case)

Thoughts?

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>

Attachment Content-Type Size
temp_tablespaces.patch text/x-patch 392 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2020-06-29 15:06:55 Re: Default setting for enable_hashagg_disk
Previous Message Stephen Frost 2020-06-29 14:31:59 Re: Fwd: PostgreSQL: WolfSSL support