1

Does postgresql have the ability to assign users of a database "priorities" in order to decide how much resources (memory, CPU,..) we allocate for the user?

Think about it like subscription modes in Cloud services: clients who has premium subscription should be allocated enough (larger) resources to meet SLA, and users who has lower subscription plans can experience some performance degradation because we don't allocate a lot of resources.

I know that we can tune some paramets like work_mem or maintenance_work_men in postgres but these are "process" level parameters, not user level.

asked Apr 23, 2024 at 9:41
4
  • Process are serving the queries of users, so what is the distinct you are you making in your last sentence? Commented Apr 23, 2024 at 14:46
  • No, not possible. You can tune work_mem, but giving someone less work_mem could result in forcing their queries to use more IO. And that could hurt your entire system pretty bad. So what is your real (performance) problem? Commented Apr 23, 2024 at 19:03
  • @FrankHeikens, I'm doing some research on resource allocation in PostgreSQL. My idea is to tailor memory allocation based on users' needs to avoid unnecessary resource wastage. I'm exploring prioritizing resource allocation for certain users. Commented Apr 25, 2024 at 13:10
  • When you set for example work_mem to 1GB, each step in the query execution that needs memory is allowed to use 1GB. If your query needs just 1MB, it uses just 1MB and leaves the rest for others. There is no waste in resources. This is what the DBMS manages for you and it does a very good job. Commented Apr 25, 2024 at 14:08

1 Answer 1

1

You can set work_mem etc at a per-user level with ALTER USER ... SET ...

https://www.postgresql.org/docs/current/sql-alteruser.html

But - that may not do what you want. If user A's query now spills to disk and takes 5 minutes to run, you may be affecting user B's services more than if you had given A more resources. If user A takes locks then that could make everybody's life difficult...

answered Apr 23, 2024 at 9:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.