X-Original-To: pgsql-admin-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 1A5E29FB1E3 for ; Tue, 1 Aug 2006 15:59:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 10836-10 for ; Tue, 1 Aug 2006 15:59:08 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.188]) by postgresql.org (Postfix) with ESMTP id 50D109FB1C3 for ; Tue, 1 Aug 2006 15:59:03 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id p77so375340nfc for ; Tue, 01 Aug 2006 11:59:01 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=cYfkfiAtaYg6zrR7S/QBDRJMpKl2gBxJy6Gu+X8/qyHggy7OoOMvGuvnCCyo25LhuXA1yiQp3ujK3wp5YAVhnCIh3cKcnIfbnfgs6j3HfwaqR2ySd6188fxf2dMb6n9tnv4LX3cDlm4VdwQ2QsKU85lNMfgl8hgOArFJ1yf4frs= Received: by 10.78.165.13 with SMTP id n13mr450995hue; Tue, 01 Aug 2006 11:59:01 -0700 (PDT) Received: by 10.78.32.10 with HTTP; Tue, 1 Aug 2006 11:59:00 -0700 (PDT) Message-ID: Date: Tue, 1 Aug 2006 13:59:00 -0500 From: "Aaron Bono" To: "Thomas Pundt" Subject: Re: Controlling CPU Usage in PostgreSQL Cc: pgsql-admin@postgresql.org In-Reply-To: <200607311101.36629.mlists@rp-online.de> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_73645_18776503.1154458740983" References: <200607311101.36629.mlists@rp-online.de> X-Google-Sender-Auth: 6d69d3fea8a37e9c X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.496 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200608/14 X-Sequence-Number: 22558 ------=_Part_73645_18776503.1154458740983 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/31/06, Thomas Pundt wrote: > > On Monday 31 July 2006 10:06, Aaron Bono wrote: > | Is there a way I can tell PostgreSQL to give session a low priority so > even > | if it does take the full CPU, it only does so if it would otherwise be > | idle? > > the "nice" command might do what you want... OK, so I tried: su - postgres -c "nice -n 19 psql my_db" The problem is, the psql command has a nice value of 19 but the PostgreSQL server process that psql has connected to is running with a nice value of 0. My assumption is that, if I then run my functions, psql will get low priority but it is the server process that is running with normal priority that will still use up all the CPU. Bottom line, I am skeptical if this will really achieve my goal - to have the functions run with low priority. Is there a way to tell PostgreSQL to change the nice value of a particular connection? I guess I could use renice but that means a lot of shell scripting to determine what PID to change - I am not a shell script expert and would rather not pursue that option. ================================================================== Aaron Bono Aranya Software Technologies, Inc. http://www.aranya.com ================================================================== ------=_Part_73645_18776503.1154458740983 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/31/06, Thomas Pundt <mlists@rp-online.de> wrote:
On Monday 31 July 2006 10:06, Aaron Bono wrote:
| Is there a way I can tell PostgreSQL to give session a low priority so even
| if it does take the full CPU, it only does so if it would otherwise be
| idle?

the "nice" command might do what you want...

 
OK, so I tried:

su - postgres -c "nice -n 19 psql my_db"

The problem is, the psql command has a nice value of 19 but the PostgreSQL server process that psql has connected to is running with a nice value of 0.  My assumption is that, if I then run my functions, psql will get low priority but it is the server process that is running with normal priority that will still use up all the CPU.

Bottom line, I am skeptical if this will really achieve my goal - to have the functions run with low priority.

Is there a way to tell PostgreSQL to change the nice value of a particular connection?  I guess I could use renice but that means a lot of shell scripting to determine what PID to change - I am not a shell script expert and would rather not pursue that option.

==================================================================
   Aaron Bono
   Aranya Software Technologies, Inc.
   http://www.aranya.com
================================================================== ------=_Part_73645_18776503.1154458740983--