#4381·postgrest

Per-request timeout

Author: steve-chavezCreated Oct 3, 2025Updated Aug 31, 2026
Labelsdifficulty: medium

Problem

Currently we support setting a statement_timeout per role and per function, but we don't have a way to support it per table or view or when resource embedding is used.

Solution

Send the timeout through an HTTP header.

http
Timeout: Second-2

The above is the Timeout header from WebDAV (ref), but it has WebDAV specific semantics so I don't think we can reuse it.

A saner option would be a Prefer header:

http
Prefer: handling=strict, timeout=2

Some drawbacks I can see is that this can be used to force failure by end users if the statement_timeout is set to a value too low (this in turn can pollute logs). For this maybe we can only allow seconds, instead of milliseconds. So only 1 second as minimum.

This timeout should also have a threshold, it cannot be too high. This threshold could be the role timeout or the function timeout.