[英]PostgreSQL - How to change tmp directory?
I am running PostgreSQL on Windows 8 using the OpenGeo Suite. 我使用OpenGeo Suite在Windows 8上运行PostgreSQL。 I'm running out of disk space on a large join.
我在大型连接上的磁盘空间不足。 How can I change the temporary directory where the "hash-join temporary file" gets stored?
如何更改存储“散列连接临时文件”的临时目录?
I am looking at the PostgreSQL configuration file and I don't see a tmp file directory. 我正在查看PostgreSQL配置文件,我没有看到tmp文件目录。
Note: I am merging two tables with 10 million rows using a variable text field which is set to a primary key. 注意:我正在使用一个设置为主键的变量文本字段合并两个包含1000万行的表。
This is my query: 这是我的查询:
UPDATE blocks
SET "PctBlack1" = race_blocks."PctBlack1"
FROM race_blocks
WHERE race_blocks.esriid = blocks.geoid10
First, make sure you have an index on these columns (of both tables). 首先,确保这些列(两个表)都有索引。 This would make PostgreSQL use less temporary files.
这将使PostgreSQL使用更少的临时文件。 Also, set the GUC
work_mem
to as high as possible, to make PostgreSQL use more memory for operations like this. 另外,将GUC
work_mem
设置为尽可能高,以使PostgreSQL为此类操作使用更多内存。
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
. 然后,您必须设置GUC
temp_tablespaces
。 You can set it per database, per user, at postgresql.conf
or inside the current session (before your query): 您可以按照每个用户,
postgresql.conf
或当前会话内部(在查询之前)为每个数据库设置它:
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: 还有一件事,用户必须具有
CREATE
权限才能使用它:
GRANT CREATE ON TABLESPACE temp_disk TO app_user;
I was unable to set the F:/pgtemp directory directly in PostgreSQL due to a lack of permissions. 由于缺少权限,我无法直接在PostgreSQL中设置F:/ pgtemp目录。
So I created a symlink to it using the windows command line "mklink /D" (a soft link). 所以我使用windows命令行“mklink / D”(软链接)创建了一个符号链接。 Now PostgreSQL writes temporary files to c:\\Users\\Administrator.opengeo\\pgdata\\Administrator\\base\\pgsql_tmp they get stored on the F: drive.
现在PostgreSQL将临时文件写入c:\\ Users \\ Administrator.opengeo \\ pgdata \\ Administrator \\ base \\ pgsql_tmp,它们存储在F:驱动器上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.