autoanalyze criteria

From: Stefan Andreatta <s(dot)andreatta(at)synedra(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: autoanalyze criteria
Date: 2013-02-22 13:57:28
Message-ID: 51277948.8060005@synedra.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Hi,

If I understand
http://www.postgresql.org/docs/9.1/static/routine-vacuuming.html
correctly, the autovacuum threshold in could be estimated like this in
PostgreSQL 9.1:

SELECT pg_stat_user_tables.relname,
pg_stat_user_tables.n_dead_tup,
CAST(current_setting('autovacuum_vacuum_threshold') AS bigint)
+ (CAST(current_setting('autovacuum_vacuum_scale_factor') AS
numeric)
* pg_class.reltuples) AS av_threshold
FROM pg_stat_user_tables
JOIN pg_class on pg_stat_user_tables.relid = pg_class.oid
ORDER BY 1;

If pg_stat_user_tables.n_dead_tup exceeds av_threshold autovacuum should
kick in. Obviously, that does rely on up-to-date statistics. Is that how
it is actually done?

2nd question: because pg_stat_user_tables.n_dead_tup is itself estimated
by ANALYZE it cannot be used as a criterion for the next autoanalyze
run, I think. Is there any way to query, whether a table currently
qualifies for autoanalyze?

Thanks and Regards,
Stefan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Clodoaldo Neto 2013-02-22 14:26:31 Access a window's frame_end row from a window function
Previous Message Schade, Jeffrey 2013-02-22 13:34:52 Re: Redefining a column within a view

Browse pgsql-hackers by date

  From Date Subject
Next Message Thom Brown 2013-02-22 13:59:18 Re: FDW for PostgreSQL
Previous Message Michael Paquier 2013-02-22 11:41:22 Re: use_remote_explain missing in docs of postgres_fdw