Re: Is there a way to limit CPU usage per user

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Tony Wasson <ajwasson(at)gmail(dot)com>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, Luki Rustianto <lukirus(at)gmail(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Is there a way to limit CPU usage per user
Date: 2006-02-10 16:01:44
Message-ID: 1139587304.22740.124.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2006-02-10 at 09:31, Tony Wasson wrote:
> On 2/9/06, Michael Fuhr <mike(at)fuhr(dot)org> wrote:
> > On Fri, Feb 10, 2006 at 11:30:04AM +0700, Luki Rustianto wrote:
> > > So how can we terminate such a long running query ?
> > >
> > > The idea is to make a crontab to periodicaly do a job to search a
> > > typical "SELECT * FROM bigtable" query who has run for some hours then
> > > to terminate them...
> >
> > Are you familiar with the statement_timeout setting?
> >
> > test=> SET statement_timeout TO 1000; -- milliseconds
> > SET
> > test=> SELECT <some long-running query>;
> > ERROR: canceling statement due to statement timeout
> >
> > If that won't work then please explain in general terms what problem
> > you're trying to solve, not how you're trying to solve it.
>
> I am also interested in being able to terminate *certain* long running
> queries. I didn't want to use statement_timeout because there are some
> queries that must run for a long time - in our case some queries that
> create summary tables. Other long running queries should be killed. I
> was able to get more granular by creating a "kill_pid" function in an
> untrusted language and selectively kill ad-hoc queries. I'd suggest
> having your non-killable queries run as one user.

Could setting a global statement_timeout of say 30000 milliseconds and
then having known long running queries set a different statement_timeout
on their own connections before running their query work?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-02-10 16:04:52 Re: Is there a way to limit CPU usage per user
Previous Message Gabor Siklos 2006-02-10 15:58:56 Out of memory error during updating huge table