zoukankan      html  css  js  c++  java
  • postgres 设置查询超时

    在postgresql.conf中设置 statement_timeout 就可以实现对所有的查询都能超过指定的时间后就断开查询:

    会话中使用:
    SET statement_timeout = 10000;
    SET
    test=# SELECT pg_sleep(15);
    ERROR: canceling statement due to statement timeout

    事务中使用:
    begin;
    set local statement_time='1000ms';
    select count(*) from mytable;
    end;

    指定数据库中使用:
    ALTER DATABASE mydatabase SET statement_timeout = 60s';

    整库设置超时:单位是ms 下面设置为10秒
    vi postgresql.conf
    statement_timeout = 10000

  • 相关阅读:
    Git
    Spring
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
  • 原文地址:https://www.cnblogs.com/mhabbyo/p/15768959.html
Copyright © 2011-2022 走看看