Postgres - 临时文件大小超过 temp_file_limit

Postgres - temporary file size exceeds temp_file_limit

我尝试使用 JDBC 游标 (setFetchSize) 发出读取所有请求(select * 来自 tblName)。 postgresql.conf 中的 temp_file_limit 属性 是 500 KB。当我执行准备好的语句时,出现 psql 异常 -

org.postgresql.util.PSQLException: ERROR: temporary file size exceeds temp_file_limit (500kB)

PostgreSQL.conf 中的文档说“# limits per-session temp file space”。 https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor 根据此 link,连接必须已禁用自动提交,而我没有禁用它。我也这样做了,但我最终遇到了同样的问题。我的理解是,如此大的读取操作在加载到结果集之前被写入一个临时文件。如果是这种情况,那么使用低 temp_file_limit,我将永远无法读取非常大的数据,即使使用游标也是如此。这对于为什么首先将其设置为可配置没有意义。

将 temp_file_limit 设置为 -1(无限制文件大小)为我解决了这个问题。我采用这种方法是否正确?

我见过会使用大量 space(有时超过 1TiB)的查询,一直持续到所有空闲 space 被用完,其他查询开始崩溃。将其设置为合理的(在我们的例子中)100GiB 会保护其他会话。

设置为 500kB 似乎确实没有意义。

仅供参考,临时文件不仅用于游标。