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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM