2

Within the latest (12, 13) versions of PostgreSQL, is there any throttling support on the user-account level, to limit how much data any query can produce and/or how much time + memory it may consume under that user account?

I want to limit specific user accounts to allow up to certain amount of data and/or time to consume within the server, before erroring with "query quota exceeded" or something like that.

Example

I want to configure user account guest to produce "quota exceeded" failure for any query that returns more than 10kb of data or takes more than 10 seconds to execute.

2
  • 2
    No, there is no such feature in Postgres. The only way you could get a filesystem quota is to use a tablespace on a really small disk and assign that to the guest user.
    – user1822
    Oct 19, 2020 at 12:36
  • I suppose that means I would have to provide extra LIMIT logic for each query to implement the data size requirements. But as for the timing requirements, is there anything usable?
    – vitaly-t
    Oct 19, 2020 at 12:40

1 Answer 1

2

There is no support for resource quotas in PostgreSQL.

Your best bet is statement_timeout:

ALTER ROLE baduser SET statement_timeout = '10s';

You cannot limit the number of rows returned, but perhaps statement_timeout is good enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.