First, make sure you have an index on these columns (of both tables). This would make PostgreSQL use less temporary files. Also, set the GUC work_mem
to as high as possible, to make PostgreSQL use more memory for operations like this.
Now, if still need, to change the temporary path, you first need to create a tablespace (if you didn't do it already):
CREATE TABLESPACE temp_disk LOCATION 'F:\pgtemp';
Then, you have to set the GUC temp_tablespaces
. You can set it per database, per user, at postgresql.conf
or inside the current session (before your query):
SET temp_tablespaces TO 'temp_disk';
UPDATE blocks
SET "PctBlack1" = race_blocks."PctBlack1"
FROM race_blocks
WHERE race_blocks.esriid = blocks.geoid10
One more thing, the user must have CREATE
privilege to use this:
GRANT CREATE ON TABLESPACE temp_disk TO app_user;