Re: Postgres becoming slow, only full vacuum fixes it - Mailing list pgsql-performance

From Mark Kirkwood
Subject Re: Postgres becoming slow, only full vacuum fixes it
Date
Msg-id 5060E7F2.3010903@catalyst.net.nz
Whole thread Raw
In response to Postgres becoming slow, only full vacuum fixes it  (Kiriakos Tsourapas <ktsour@gmail.com>)
Responses Re: Postgres becoming slow, only full vacuum fixes it  (Kiriakos Tsourapas <ktsour@gmail.com>)
List 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


pgsql-performance by date:

Previous
From: Ondrej Ivanič
Date:
Subject: Re: Postgres becoming slow, only full vacuum fixes it
Next
From: henk de wit
Date:
Subject: Spurious failure to obtain row lock possible in PG 9.1?