laravel 如何从应用程序级别设置 postgres 查询执行超时?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38142257/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set postgres query execution timeout from application level?
提问by Dipu R
I am creating a web application in php(using Laravel), I would like to set a query execution timeout to PostgreSQL but I don't have access to server configuration, so is there any other way set query execution timeout through application level?
我正在 php(使用 Laravel)中创建一个 Web 应用程序,我想将查询执行超时设置为 PostgreSQL,但我无权访问服务器配置,那么还有其他方法可以通过应用程序级别设置查询执行超时吗?
Thank you
谢谢
回答by greg
Simply send the following statement:
只需发送以下声明:
set statement_timeout TO 100;
Postgresql will then cancel all queries exceeding 100ms.
然后 Postgresql 将取消所有超过 100 毫秒的查询。