Re: Question about slow queries...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Good, Thomas" <tgood(at)svcmcny(dot)org>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Question about slow queries...
Date: 2010-05-27 14:03:28
Message-ID: 14435.1274969008@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Good, Thomas" <tgood(at)svcmcny(dot)org> writes:
> I have a question about a query that starts out fine and over time slows to a halt - but only on a webhosted site. Locally it does fine.

> The query is a singleton select (no joins), hitting a table with about
> 5,000 records in it. Over time the query slows to a crawl and I have to
> dump and rebuild/repopulate to restore efficiency. Vacuum does nothing
> but a dump and reload fixes the problem and the query runs lightning
> fast again -- for a period of a week or so.

If a dump and reload fixes it then you have table-bloat or index-bloat
problems. A simple VACUUM won't fix that once it's happened. You need
to VACUUM more often so that it doesn't get bloated in the first place.

> Locally I'm running 8.4.2, the webhost is 8.1.18

... and the reason for the difference is probably that 8.4.x has a
reasonably decent autovacuum facility, which 8.1.x does not. Suggest
bugging your webhost provider to provide a less obsolete version of
Postgres.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2010-05-27 14:05:42 Re: Do not understand "SETOF RECORD" - therefore can not use ODBC-link
Previous Message James Kitambara 2010-05-27 13:55:21 Fw: Re: help