pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Madison Kelly <linux@alteeve.com>
To: Gary Doades <gpd@gpdnet.co.uk>
Cc: pgsql-performance@postgresql.org
Subject: Re: DB is slow until DB is reloaded
Date: Mon, 04 Jan 2010 15:53:41 -0500
Message-ID: <4B425555.6020709@alteeve.com> (raw)
In-Reply-To: <4B425222.7070905@gpdnet.co.uk>
References: <4B423D22.7040803@alteeve.com>
	<4B424215.70605@pinpointresearch.com>
	<4B424FF6.40207@alteeve.com>
	<4B425222.7070905@gpdnet.co.uk>

Gary Doades wrote:
>  From your queries it definitely looks like its your stats that are the 
> problem. When the stats get well out of date the planner is choosing a 
> hash join because it thinks thousands of rows are involved where as only 
> a few are actually involved. Thats why, with better stats, the second 
> query is using a loop join over very few rows and running much quicker.
> 
> Therefore it's ANALYZE you need to run as well as regular VACUUMing. 
> There should be no need to VACUUM FULL at all as long as you VACUUM and 
> ANALYZE regularly. Once a day may be enough, but you don't say how long 
> it takes your database to become "slow".
> 
> You can VACUUM either the whole database (often easiest) or individual 
> tables if you know in more detail what the problem is and that only 
> certain tables need it.
> 
> Setting up autovacuum may well be sufficient.
> 
> Cheers,
> Gary.

That explains things, thank you!

For the record; It was taking a few months for the performance to become 
intolerable. I've added CLUSTER -> ANALYZE -> VACUUM to my nightly 
routine and dropped the VACUUM FULL call. I'll see how this works.

Cheers!

Madi



view thread (25+ messages)  latest in thread

Message-ID: <4B425555.6020709@alteeve.com>
Permalink:  ../4B425555.6020709@alteeve.com/
Also on:    postgresql.org/message-id/4B425555.6020709@alteeve.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: linux@alteeve.com, gpd@gpdnet.co.uk
  Subject: Re: DB is slow until DB is reloaded
  In-Reply-To: <4B425555.6020709@alteeve.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox