# 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/programmy/linux/limit-execution-time-of-statements.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
