【问题标题】:Set query timeout to 60mins for all postgres database将所有 postgres 数据库的查询超时设置为 60 分钟
【发布时间】:2020-09-17 08:47:01
【问题描述】:

我必须将 Postgres 数据库的查询超时设置为 60 分钟。我有以下 Postgres 数据库的配置文件。

  1. pg_ctl.conf
  2. pg_hba.conf
  3. pg_ident.conf
  4. postgresql.conf
  5. start.conf

在 postgresql.conf 文件中,我看到有字段;

#statement_timeout = 0      # in milliseconds, 0 is disabled
#lock_timeout = 0           # in milliseconds, 0 is disabled

我的问题是,我需要在 60 分钟内取消注释/设置哪个字段?

有人请帮忙吗?或者我需要在配置文件中添加其他内容吗?

提前致谢。

【问题讨论】:

  • 与您的问题无关,但是:与您的问题无关,但是:Postgres 9.1 是no longer supported,您应该尽快计划升级。

标签: postgresql devops postgresql-9.1


【解决方案1】:

要为查询超时设置全局默认值,请使用statement_timeout,例如

statement_timeout = 60min

Quote from the manual

中止任何花费超过指定时间的语句。 [...] 如果指定此值时没有单位,则以毫秒为单位。零值(默认值)禁用超时。
超时时间是从命令到达服务器到服务器完成的时间。

如果您只想为特定用户执行此操作,则无需全局执行此操作(针对每个用户):

alter user the_user_to_control 
    set statement_timeout = '60min';

这将更改当前数据库中指定用户的值。如果您真的在每个数据库中都需要它,则需要在每个数据库中运行该语句语句。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-04
    • 1970-01-01
    • 1970-01-01
    • 2017-05-06
    • 1970-01-01
    相关资源
    最近更新 更多