Re: Postgres becoming slow, only full vacuum fixes it

From: Mark Kirkwood <mark(dot)kirkwood(at)catalyst(dot)net(dot)nz>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Postgres becoming slow, only full vacuum fixes it
Date: 2012-09-24 23:08:34
Message-ID: 5060E7F2.3010903@catalyst.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 24/09/12 22:33, Kiriakos Tsourapas wrote:
> Hi,
>
> The problem : Postgres is becoming slow, day after day, and only a full vacuum fixes the problem.
>
>
>
> My postgresql.conf file :
> ======================
> port = 5433 # (change requires restart)
> max_connections = 100 # (change requires restart)
> shared_buffers = 256MB # min 128kB. DoubleIP - Default was 32MB
> synchronous_commit = off # immediate fsync at commit. DoubleIP - Default was on
> effective_cache_size = 512MB # DoubleIP - Default was 128MB
> log_destination = 'stderr' # Valid values are combinations of
> logging_collector = on # Enable capturing of stderr and csvlog
> silent_mode = on # Run server silently.
> log_line_prefix = '%t %d %u ' # special values:
> log_autovacuum_min_duration = 0 # -1 disables, 0 logs all actions and
> autovacuum_naptime = 28800 # time between autovacuum runs. DoubleIP - default was 1min
> autovacuum_vacuum_threshold = 100 # min number of row updates before
> autovacuum_vacuum_scale_factor = 0.0 # fraction of table size before vacuum. DoubleIP - default was 0.2
> datestyle = 'iso, mdy'
> lc_messages = 'en_US.UTF-8' # locale for system error message
> lc_monetary = 'en_US.UTF-8' # locale for monetary formatting
> lc_numeric = 'en_US.UTF-8' # locale for number formatting
> lc_time = 'en_US.UTF-8' # locale for time formatting
> default_text_search_config = 'pg_catalog.english'
>

Given that vacuum full fixes the issue I suspect you need to have
autovacuum set wake up much sooner, not later. So autovacuum_naptime =
28800 or even = 60 (i.e the default) is possibly too long. We have
several database here where I change this setting to 10 i.e:

autovacuum_naptime = 10s

in order to avoid massive database bloat and queries that get slower and
slower...

You might want to be a bit *less* aggressive with
autovacuum_vacuum_scale_factor - I usually have this at 0.1, i.e:

autovacuum_vacuum_scale_factor = 0.1

otherwise you will be vacuuming all the time - which is usually not what
you want (not for all your tables anyway).

regards

Mark

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Albe Laurenz 2012-09-25 10:48:30 Re: Spurious failure to obtain row lock possible in PG 9.1?
Previous Message Ondrej Ivanič 2012-09-24 21:43:30 Re: Postgres becoming slow, only full vacuum fixes it