Re: Performance degrades until dump/restore

Lists: pgsql-general
From: Chris <bajasands(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Performance degrades until dump/restore
Date: 2012-04-19 06:35:26
Message-ID: CAMv1wqf0q=pYN6H5LD+6AY44BzY5iczuGJ7SKCaN2hyHbUQsBQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello,
I'm using PG 9.1. Data is streaming into one particularly large table (at
11 million rows currently) on a constant basis. It is pretty much all
inserts, very little updates or deletes (if any).
After a week or so, query performance on this table turns abysmal. If I
dump the db, then restore, performance turns great for a while before it
starts to bog down again in the following days.

So far, the only answers I can find by searching is to turn autovacuum on.
But it should already by on by default. The only setting that I have
modified was to increase shared buffer.

I'm not really sure where to go from here. Anybody have any suggestions on
what the problem(s) might be and how to rectify it?

Thanks!


From: Chris Travers <chris(dot)travers(at)gmail(dot)com>
To: Chris <bajasands(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance degrades until dump/restore
Date: 2012-04-19 06:47:39
Message-ID: CAKt_ZfsX7+fR6nOc1FABRosAs2-yCFBjVRaB1DpMhBs5_6bXvA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Is autovacuum running?

Are tables being analyzed from time to time?

Best Wishes,
Chris Travers


From: Willy-Bas Loos <willybas(at)gmail(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance degrades until dump/restore
Date: 2012-04-19 06:48:37
Message-ID: CAHnozTi=1+eVE-2ErNve7WFXWKPpNWZzo5_vc++4y=d4Xonkug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

what performance, insert or select?

On Thu, Apr 19, 2012 at 8:35 AM, Chris <bajasands(at)gmail(dot)com> wrote:

> Hello,
> I'm using PG 9.1. Data is streaming into one particularly large table (at
> 11 million rows currently) on a constant basis. It is pretty much all
> inserts, very little updates or deletes (if any).
> After a week or so, query performance on this table turns abysmal. If I
> dump the db, then restore, performance turns great for a while before it
> starts to bog down again in the following days.
>
> So far, the only answers I can find by searching is to turn autovacuum
> on. But it should already by on by default. The only setting that I have
> modified was to increase shared buffer.
>
> I'm not really sure where to go from here. Anybody have any suggestions on
> what the problem(s) might be and how to rectify it?
>
> Thanks!
>
>

--
"Patriotism is the conviction that your country is superior to all others
because you were born in it." -- George Bernard Shaw


From: Chris <bajasands(at)gmail(dot)com>
To: Chris Travers <chris(dot)travers(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance degrades until dump/restore
Date: 2012-04-19 14:09:18
Message-ID: CAMv1wqcJAj_g0HUZ2__w-e_hc2YXFUkQBOrU+5kLid+A3pREaQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi Chris,
It is postgres 9.1, with default settings. The autovacuum settings are all
commented out, I have not change dthem. My understanding is that analyze is
also run automatically by default.

So, I believe the answer to both questions is 'Yes'.

On Thu, Apr 19, 2012 at 12:47 AM, Chris Travers <chris(dot)travers(at)gmail(dot)com>wrote:

> Is autovacuum running?
>
> Are tables being analyzed from time to time?
>
> Best Wishes,
> Chris Travers
>


From: Andy Colson <andy(at)squeakycode(dot)net>
To: Chris <bajasands(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance degrades until dump/restore
Date: 2012-04-19 15:22:23
Message-ID: 4F902DAF.3090003@squeakycode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 4/19/2012 1:35 AM, Chris wrote:
> Hello,
> I'm using PG 9.1. Data is streaming into one particularly large table
> (at 11 million rows currently) on a constant basis. It is pretty much
> all inserts, very little updates or deletes (if any).
> After a week or so, query performance on this table turns abysmal. If I
> dump the db, then restore, performance turns great for a while before it
> starts to bog down again in the following days.

Can you post an "explain analyze" when its fast, and then again when its
slow?

Are you leaving transactions open? (does "select * from
pg_stat_activity" show any "idle in transaction"?)

Does memory usage increase during the week so it starts using swap?

-Andy


From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Chris <bajasands(at)gmail(dot)com>
Cc: Chris Travers <chris(dot)travers(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Performance degrades until dump/restore
Date: 2012-04-19 15:40:36
Message-ID: CAF-3MvPgOX0m2EditVtCpqPAttp3HPkn+55qKQye2MZHnnUyeA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 19 April 2012 16:09, Chris <bajasands(at)gmail(dot)com> wrote:
> Hi Chris,
> It is postgres 9.1, with default settings.  The autovacuum settings are all
> commented out, I have not change dthem. My understanding is that analyze is
> also run automatically by default.
>
> So, I believe the answer to both questions is 'Yes'.

Most likely autovacuum is falling behind with default settings. If
that's the case, increasing the frequency with which it checks that
particular table should help.

Or you can explicitly run VACUUM ANALYZE after a batch of inserts finished.
--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.


From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Chris <bajasands(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance degrades until dump/restore
Date: 2012-04-19 15:42:59
Message-ID: CAOR=d=29VVUA7beOy4mJrvU6waCNJs9MxGCZp4T==TW1Ki+W3Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

From: Chris <bajasands(at)gmail(dot)com>
To: Andy Colson <andy(at)squeakycode(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance degrades until dump/restore
Date: 2012-04-19 17:02:31
Message-ID: CAMv1wqcF5WtQcFWBJfbi2+G6_5D_5UDxQrx8XAEtxLMxfcfLFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi Andy,
Thanks for your reply. I don't know the answers to your questions off the
top of my head, so you have given me some things to look into (open
transactions, memory swap, etc).
Now I am suspecting that memory is a partial culprit as I just discovered
that rebooting (hadn't had the opportunity to do that) also seems to boost
query performance to a lesser degree. I'm going to take a hard look at that.

It will take me several days to come up with an "explain analyze" when it's
fast and when it's slow, so I'll come back with that when I have it ready
if I had not resolved the issue by then. Good idea.

>
> Can you post an "explain analyze" when its fast, and then again when its
> slow?
>
> Are you leaving transactions open? (does "select * from pg_stat_activity"
> show any "idle in transaction"?)
>
> Does memory usage increase during the week so it starts using swap?
>
> -Andy
>


From: Chris <bajasands(at)gmail(dot)com>
To: Alban Hertroys <haramrae(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance degrades until dump/restore
Date: 2012-04-19 17:04:33
Message-ID: CAMv1wqeMYcWO-Z5rwA-R-5v4mK_8RQA_BWVxa8hqFesaew1Lbw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

That's a great idea Alban. I think that between your suggestion and
looking into memory & swap, we may be on to something. I'll post back with
more details (per the wiki suggestions) if I'm not able to get this
resolved.
Thanks!
On Thu, Apr 19, 2012 at 9:40 AM, Alban Hertroys <haramrae(at)gmail(dot)com> wrote:

> On 19 April 2012 16:09, Chris <bajasands(at)gmail(dot)com> wrote:
> > Hi Chris,
> > It is postgres 9.1, with default settings. The autovacuum settings are
> all
> > commented out, I have not change dthem. My understanding is that analyze
> is
> > also run automatically by default.
> >
> > So, I believe the answer to both questions is 'Yes'.
>
> Most likely autovacuum is falling behind with default settings. If
> that's the case, increasing the frequency with which it checks that
> particular table should help.
>
> Or you can explicitly run VACUUM ANALYZE after a batch of inserts finished.
> --
> If you can't see the forest for the trees,
> Cut the trees and you'll see there is no forest.
>