postgresql 控制命令执行时长 statement_timeout

statement_timeout 在 postgresql 被用来控制语句执行时长,单位是ms。

$ vi postgresql.conf 
#statement_timeout = 0                  # in milliseconds, 0 is disabled

默认是0,表示语句可以一直执行下去。

如果设置为1440000,那就意味着语句最多可以执行 1440000ms = 1440s = 24min。
建议设置为0,禁用该参数。

postgres=# select *
postgres-# from pg_settings ps
postgres-# where 1=1
postgres-# and ps.name like '%statement_timeout%'
postgres-# ;
-[ RECORD 1 ]---------------------------------------------------
name       | statement_timeout
setting    | 1440000
unit       | ms
category   | Client Connection Defaults / Statement Behavior
short_desc | Sets the maximum allowed duration of any statement.
extra_desc | A value of 0 turns off the timeout.
context    | user
vartype    | integer
source     | configuration file
min_val    | 0
max_val    | 2147483647
enumvals   | 
boot_val   | 0
reset_val  | 14400000
sourcefile | /etc/postgresql/9.1/main/postgresql.conf
sourceline | 473
原文地址:https://www.cnblogs.com/ctypyb2002/p/9793044.html