Thread: Limiting postgresql resources

Limiting postgresql resources

From
"Joey K."
Date:
Hello,

Is it possible to limit cpu/memory resources to queries on postgres something akin to limits.conf on Linux?

We have a couple of databases (pg 8.2.7)  serving 500K - 1M records. For various reasons, users are allowed to run queries against the database via a web based query interface. These queries are mostly used to generate reports.

Some times users write inefficient queries that brings the entire database server (runs webserver as well) to it's knees affecting others users on the system.

So, is it possible to kill a query thats running for x minutes with 50%+ CPU load and using y MB of memory?

In a perfect world, we would address such issues in the application design/database design and/or hardware. But our application is in an imperfect world where such resources are unavailable.

Thanks in advance,
Joey


Re: Limiting postgresql resources

From
Tom Lane
Date:
"Joey K." <pguser@gmail.com> writes:
> So, is it possible to kill a query thats running for x minutes with 50%+ CPU
> load and using y MB of memory?

There's statement_timeout ...

            regards, tom lane