PG中的statement_timeout、idle_in_transaction_session_timeout、idle_session_timeout等常用的 timeout 参数

0    144    1

Tags:

👉 本文共约2327个字,系统预计阅读时间或需9分钟。

简介

PostgreSQL 有很多与超时相关的参数可供用户设置,包括:

  • statement_timeout: Sets the maximum allowed duration of any statement. 用于限制单个 query 执行的时间 在PG 9.4中就提供了。
  • lock_timeout:Abort any statement that waits longer than the specified amount of time while attempting to acquire a lock on a table, index, row, or other database object. 在PG 9.4中就提供了。
  • idle_in_transaction_session_timeout: Sets the maximum allowed idle time between queries, when in a transaction. 用于限制在事务中闲置的时长 在PG 9.6中就提供了。
  • idle_session_timeout: Sets the maximum allowed idle time between queries, when not in a transaction. 用于限制连接处于空间的时长 PG 14新增
  • client_connection_check_interval:Sets the time interval between optional checks that the client is still connected, while running queries. PG 14新增

statement_timeout

在PG 9.4中就提供了。

PostgreSQL 中长事务往往会带来一些问题,比如 table bloat(由于旧版本记录不能及时回收)、占用资源(锁、内存)等,因此有些实例会设置一个合理的 statement_timeout 来自动杀死运行时间过长的查询。

但这个参数对于 idle in transaction 的 session 不起作用,比如:

开启事务但一直不 commit,该 session 一直处于 idle in transaction 状态,在另一个客户端查询:

statement_timeout (integer)

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!
PG中的statement_timeout、idle_in_transaction_session_timeout、idle_session_timeout等常用的 timeout 参数后续精彩内容已被小麦苗无情隐藏,请输入验证码解锁本站所有文章!
验证码:
请先关注本站微信公众号,然后回复“验证码”,获取验证码。在微信里搜索“DB宝”或者“www_xmmup_com”或者微信扫描右侧二维码都可以关注本站微信公众号。

标签:

Avatar photo

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复

嘿,我是小麦,需要帮助随时找我哦。
  • 18509239930
  • 个人微信

  • DB宝
  • 个人邮箱
  • 点击加入QQ群
  • 个人微店

  • 回到顶部