From: Scott Marlowe <smarlowe@g2switchworks.com>
To: Aaron Bono <postgresql@aranya.com>
Cc: Thomas Pundt <thomas.pundt@rp-online.de>
Cc: pgsql-admin@postgresql.org
Subject: Re: Controlling CPU Usage in PostgreSQL
Date: Tue, 01 Aug 2006 14:22:31 -0500
Message-ID: <1154460151.7882.7.camel@state.g2switchworks.com> (raw)
In-Reply-To: <bf05e51c0608011159h74ac3a44wdb98b8ab32803275@mail.gmail.com>
References: <bf05e51c0607310106w415fe34ep4b5046984cd11341@mail.gmail.com>
<200607311101.36629.mlists@rp-online.de>
<bf05e51c0608011159h74ac3a44wdb98b8ab32803275@mail.gmail.com>
On Tue, 2006-08-01 at 13:59, Aaron Bono wrote:
> 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.
This is one of those things that only seems like a good idea at the
time.
While nice-ing the whole of a postgresql server is doable, nice-ing
individual connections is no advisable.
You can reach a bad state caused by "priority inversion". Search the
lists (not just admin) for that phrase and you should find out what I
mean. This should probably be a FAQ, as it shows up every few months.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: smarlowe@g2switchworks.com, postgresql@aranya.com, thomas.pundt@rp-online.de
Subject: Re: Controlling CPU Usage in PostgreSQL
In-Reply-To: <1154460151.7882.7.camel@state.g2switchworks.com>
References: <bf05e51c0607310106w415fe34ep4b5046984cd11341@mail.gmail.com> <200607311101.36629.mlists@rp-online.de> <bf05e51c0608011159h74ac3a44wdb98b8ab32803275@mail.gmail.com> <1154460151.7882.7.camel@state.g2switchworks.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox