首页 > 解决方案 > Postgres 查询在 30 秒后超时

问题描述

有一个查询会在 30 秒后保持超时。我在 Stackoverflow 上看到了一些与我面临的问题相似的帖子,唯一让我的问题不同的是,我没有使用 DSN-LESS 连接,我使用的是 ODBC ADMINISTRATOR。

以下错误是我收到的错误:

16:33:16.06 System.Data.Odbc.OdbcException (0x80131937):错误 [57014] 错误:由于语句超时而取消语句;

我想我的问题是,如何使用 ODBC Administrator 增加连接超时?

任何帮助,将不胜感激

标签: postgresqlodbcconnection-stringpgadmin

解决方案


您可以尝试在每个数据库会话中运行类似于:

postgres=# set statement_timeout='300s';
SET
postgres=# show statement_timeout;
 statement_timeout 
-------------------
 5min
(1 row)

postgres=#

为了避免在每个数据库会话中这样做,在 postgresql.conf 中更改此参数会更容易:将为所有数据库会话启用新设置。


推荐阅读