Re: Controlling CPU Usage in PostgreSQL

From: "Aaron Bono" <postgresql(at)aranya(dot)com>
To: "Scott Marlowe" <smarlowe(at)g2switchworks(dot)com>
Cc: "Thomas Pundt" <thomas(dot)pundt(at)rp-online(dot)de>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Controlling CPU Usage in PostgreSQL
Date: 2006-08-01 19:52:32
Message-ID: bf05e51c0608011252g275067a3i178661b7e9a1cc1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On 8/1/06, Scott Marlowe <smarlowe(at)g2switchworks(dot)com> wrote:
>
> On Tue, 2006-08-01 at 13:59, Aaron Bono wrote:
> > On 7/31/06, Thomas Pundt <mlists(at)rp-online(dot)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.
>

I am guessing my best bet is to wait until performance is becomming an issue
(or just before) and then create a data warehouse on a separate server.
That would be much easier to implement and would isolate the reporting from
production.

Thanks for the input.

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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Chris Mair 2006-08-01 21:56:04 Re: Controlling CPU Usage in PostgreSQL
Previous Message Joshua D. Drake 2006-08-01 19:43:36 Re: Controlling CPU Usage in PostgreSQL