Lists: | pgsql-performance |
---|
From: | S Arvind <arvindwill(at)gmail(dot)com> |
---|---|
To: | pgsql-performance(at)postgresql(dot)org |
Subject: | Running some query in low priority |
Date: | 2009-11-05 09:36:31 |
Message-ID: | abf9211d0911050136g48739f0ft53b63f96cddf706@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
Hi Developers and Tuners,
Is there any way to run some query in low priority and some query
in higher priority in pg. The main reason for this is i need my main
application(high priority) to be undisturbed by the sub application(low
priority) which is running on same DB. Is there anyother good way to operate
this?
Arvind S
*
"Many of lifes failure are people who did not realize how close they were to
success when they gave up."
-Thomas Edison*
From: | Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com> |
---|---|
To: | S Arvind <arvindwill(at)gmail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Running some query in low priority |
Date: | 2009-11-05 09:38:55 |
Message-ID: | 2f4958ff0911050138n3f246b7ck6182cb702ac48e91@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
On Thu, Nov 5, 2009 at 9:36 AM, S Arvind <arvindwill(at)gmail(dot)com> wrote:
> Hi Developers and Tuners,
> Is there any way to run some query in low priority and some query
> in higher priority in pg. The main reason for this is i need my main
> application(high priority) to be undisturbed by the sub application(low
> priority) which is running on same DB. Is there anyother good way to operate
> this?
>
other than manually re-nicing back end, no.
--
GJ
From: | Greg Stark <gsstark(at)mit(dot)edu> |
---|---|
To: | Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com> |
Cc: | S Arvind <arvindwill(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Running some query in low priority |
Date: | 2009-11-05 11:32:22 |
Message-ID: | 407d949e0911050332n5ef355c1y156dcd26aa28d222@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
2009/11/5 Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>:
>
>
> On Thu, Nov 5, 2009 at 9:36 AM, S Arvind <arvindwill(at)gmail(dot)com> wrote:
>>
>> Hi Developers and Tuners,
>> Is there any way to run some query in low priority and some query
>> in higher priority in pg. The main reason for this is i need my main
>> application(high priority) to be undisturbed by the sub application(low
>> priority) which is running on same DB. Is there anyother good way to operate
>> this?
>
> other than manually re-nicing back end, no.
And unfortunately this doesn't really work very well. renicing only
affects cpu priority and usually it's i/o priority you want to adjust.
Even if you can adjust i/o priority per process on your operating
system the database often does i/o work for one process in another
process or has times when a process is waiting on another process to
finish i/o. So lowering the i/o priority of the low priority process
might not have the desired effect of speeding up other processes.
Usually this isn't a problem unless you have a large batch load or
something like that happening which consumes all available i/o. In
that case you can sometimes reduce the i/o demand by just throttling
the rate at which you send data to or read data from the server.
--
greg
From: | S Arvind <arvindwill(at)gmail(dot)com> |
---|---|
To: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Running some query in low priority |
Date: | 2009-11-05 13:20:19 |
Message-ID: | abf9211d0911050520t72a5d6dfv877ced07077b11@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
Thank Greg and Grzegorz,
As told i have large batch load to the postgres which i need to be
run in low priority. Is it really throttling the data will help to lower the
postgres workload for some queries?
-Arvind S
2009/11/5 Greg Stark <gsstark(at)mit(dot)edu>
> 2009/11/5 Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>:
> >
> >
> > On Thu, Nov 5, 2009 at 9:36 AM, S Arvind <arvindwill(at)gmail(dot)com> wrote:
> >>
> >> Hi Developers and Tuners,
> >> Is there any way to run some query in low priority and some
> query
> >> in higher priority in pg. The main reason for this is i need my main
> >> application(high priority) to be undisturbed by the sub application(low
> >> priority) which is running on same DB. Is there anyother good way to
> operate
> >> this?
> >
> > other than manually re-nicing back end, no.
>
> And unfortunately this doesn't really work very well. renicing only
> affects cpu priority and usually it's i/o priority you want to adjust.
> Even if you can adjust i/o priority per process on your operating
> system the database often does i/o work for one process in another
> process or has times when a process is waiting on another process to
> finish i/o. So lowering the i/o priority of the low priority process
> might not have the desired effect of speeding up other processes.
>
> Usually this isn't a problem unless you have a large batch load or
> something like that happening which consumes all available i/o. In
> that case you can sometimes reduce the i/o demand by just throttling
> the rate at which you send data to or read data from the server.
>
>
> --
> greg
>
From: | Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com> |
---|---|
To: | S Arvind <arvindwill(at)gmail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Running some query in low priority |
Date: | 2009-11-05 13:25:20 |
Message-ID: | 2f4958ff0911050525w678925uc8f63fe966951ef5@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
On Thu, Nov 5, 2009 at 1:20 PM, S Arvind <arvindwill(at)gmail(dot)com> wrote:
> Thank Greg and Grzegorz,
> As told i have large batch load to the postgres which i need to be
> run in low priority. Is it really throttling the data will help to lower the
> postgres workload for some queries?
>
depends on what you are actually trying to achieve.
If it is an insert of some sort, than divide it up. If it is a query that
runs over data, use limits, and do it in small batches. Overall, divide in
conquer approach works in these scenarios.
--
GJ
From: | Matthew Wakeling <matthew(at)flymine(dot)org> |
---|---|
To: | Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com> |
Cc: | S Arvind <arvindwill(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Running some query in low priority |
Date: | 2009-11-05 13:39:35 |
Message-ID: | alpine.DEB.2.00.0911051335410.19472@aragorn.flymine.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
On Thu, 5 Nov 2009, Grzegorz Jaśkiewicz wrote:
> If it is an insert of some sort, than divide it up. If it is a query that runs over data,
> use limits, and do it in small batches. Overall, divide in conquer approach works in
> these scenarios.
Unfortunately, dividing the work up can cause a much greater load, which
would make things worse. If you are inserting in smaller chunks and
committing more frequently that can reduce performance. If you split up
queries with limit and offset, that will just multiply the number of times
the query has to be run. Each time, the query will be evaluated, the first
<offset> rows thrown away, and the next <limit> rows returned, which will
waste a huge amount of time.
If you are inserting data, then use a COPY from stdin, and then you can
throttle the data stream. When you are querying, declare a cursor, and
fetch from it at a throttled rate.
Matthew
--
Bashir: The point is, if you lie all the time, nobody will believe you, even
when you're telling the truth. (RE: The boy who cried wolf)
Garak: Are you sure that's the point, Doctor?
Bashir: What else could it be? -- Star Trek DS9
Garak: That you should never tell the same lie twice. -- Improbable Cause
From: | Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com> |
---|---|
To: | Matthew Wakeling <matthew(at)flymine(dot)org> |
Cc: | S Arvind <arvindwill(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Running some query in low priority |
Date: | 2009-11-05 13:42:56 |
Message-ID: | 2f4958ff0911050542m479791c6lb0772f23a474cd37@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
2009/11/5 Matthew Wakeling <matthew(at)flymine(dot)org>
> On Thu, 5 Nov 2009, Grzegorz Jaśkiewicz wrote:
>
>> If it is an insert of some sort, than divide it up. If it is a query that
>> runs over data,
>> use limits, and do it in small batches. Overall, divide in conquer
>> approach works in
>> these scenarios.
>>
>
> Unfortunately, dividing the work up can cause a much greater load, which
> would make things worse. If you are inserting in smaller chunks and
> committing more frequently that can reduce performance. If you split up
> queries with limit and offset, that will just multiply the number of times
> the query has to be run. Each time, the query will be evaluated, the first
> <offset> rows thrown away, and the next <limit> rows returned, which will
> waste a huge amount of time.
>
> If you are inserting data, then use a COPY from stdin, and then you can
> throttle the data stream. When you are querying, declare a cursor, and fetch
> from it at a throttled rate.
>
as with everything, you have to find the right balance. I think he is
looking for low impact, not speed. So he has to trade one for another. Find
a small enough batch size, but not too small, cos like you said - things
will have too much impact otherwise.
--
GJ
From: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> |
---|---|
To: | S Arvind <arvindwill(at)gmail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Running some query in low priority |
Date: | 2009-11-05 18:02:09 |
Message-ID: | dcc563d10911051002q31651d40x4b04020b9e5f6ae@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
On Thu, Nov 5, 2009 at 2:36 AM, S Arvind <arvindwill(at)gmail(dot)com> wrote:
> Hi Developers and Tuners,
> Is there any way to run some query in low priority and some query
> in higher priority in pg. The main reason for this is i need my main
> application(high priority) to be undisturbed by the sub application(low
> priority) which is running on same DB. Is there anyother good way to operate
> this?
Are you IO or CPU bound? If CPU bound get more CPUs. If IO bound see
about getting more IO, specifically a fast RAID controller with
Battery Backed Cache, and a fair number of fast hard drives in a
RAID-10. Trying to throttle one thing to get the others to run faster
can only buy you so much time. As load increases you'll need more CPU
or IO.
If the thing you're doing is CPU intensive, and it needs lots of CPUs,
then look at some form of replication to other boxes to throw more
CPUs at the problem.