Re: Question about slow queries... - Mailing list pgsql-sql

From Tom Lane
Subject Re: Question about slow queries...
Date
Msg-id 14435.1274969008@sss.pgh.pa.us
Whole thread Raw
In response to Question about slow queries...  ("Good, Thomas" <tgood@svcmcny.org>)
List pgsql-sql
"Good, Thomas" <tgood@svcmcny.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.
Locallyit 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


pgsql-sql by date:

Previous
From: James Kitambara
Date:
Subject: Fw: Re: help
Next
From: Tom Lane
Date:
Subject: Re: Do not understand "SETOF RECORD" - therefore can not use ODBC-link