Обсуждение: VACUUM and other maintenance work

Поиск
Список
Период
Сортировка

VACUUM and other maintenance work

От
"Christian Hofmann"
Дата:
Hello,

regarding the last messages dealing with losing data when not vacuum the
database regulary, I have some questions:

1. When I make the query "SELECT datname, age(datfrozenxid) FROM
pg_database;" I get the following result:

datname;age
test;1073742421
my_db;1073742732
template1;1073742548
template0;19741

Everytime I am repeating this query, the values are increasing by 5. I
thinks thats ok?

It is not possible to vacuum the template0 database because it is switched
of, and so I can't connect to the databse.
Does an overflow of the datfrozenxid in the template0 DB matter or cause
problems in any way?

2. Connecting, maybe by a cron job, to the database and submitting the query
"VACUUM ANALYZE" will prevent me from losing data from not vacuuming. Is
that correct?

3. Are there other things I should do regulary in order not to lose the data
in the database?

Thanks,

Christian



Re: VACUUM and other maintenance work

От
Tom Lane
Дата:
"Christian Hofmann" <christian.hofmann@gmx.de> writes:
> 2. Connecting, maybe by a cron job, to the database and submitting the query
> "VACUUM ANALYZE" will prevent me from losing data from not vacuuming. Is
> that correct?

You have to do this in each connectable database (yes, you can ignore
template0).  Most people prefer to use the vacuumdb script rather than
invent their own.

Alternatively you can use the pg_autovacuum daemon.

There are details about maintenance tasks in the manual:
http://www.postgresql.org/docs/8.0/static/maintenance.html
(adjust URL to match your PG version)

            regards, tom lane