1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Limit Execution Time Of Statements as a postgres til.

This commit is contained in:
jbranchaud
2015-06-21 10:03:59 -05:00
parent c0a79616e7
commit e913bef0ab
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
# Limit Execution Time Of Statements
You can limit the amount of time that postgres will execute a statement
by setting a hard timeout. By default the timeout is 0 (see `show
statement_timeout;`) which means statements will be given as much time as
they need.
If you do want to limit your statements, to say, 1 second, you can set the
execution time like so
```sql
> set statement_timeout = '1s';
SET
> show statement_timeout;
statement_timeout
-------------------
1s
(1 row)
```
Any queries taking longer than 1 second will be aborted with the following
message output
```
ERROR: canceling statement due to statement timeout
```