Re: VACUUM ANALYZE -vs- ANALYZE on an insert-only table. - Mailing list pgsql-general

From Tom Lane
Subject Re: VACUUM ANALYZE -vs- ANALYZE on an insert-only table.
Date
Msg-id 16722.1071529301@sss.pgh.pa.us
Whole thread Raw
In response to VACUUM ANALYZE -vs- ANALYZE on an insert-only table.  ("Matt Gordon" <m.gordon@f5.com>)
List pgsql-general
"Matt Gordon" <m.gordon@f5.com> writes:
> If I have a table that I only use for INSERTs and queries (no UPDATEs
> or DELETEs), is it enough to just run ANALYZE on the table instead of
> VACUUM ANALYZE?  In other words, is running a VACUUM on a table useful
> if all that you're doing is INSERTing into it?

It's of marginal value: it ensures that the commit status bits of the
table's rows are up-to-date, which can save work for subsequent SELECTs.

You *must* vacuum every table in your database at least once every
billion transactions to avoid transaction wraparound problems; and in
practice you probably want to do it more frequently than that to avoid
unreasonable growth of the pg_clog/ files.  But most people don't need
daily VACUUMs to meet that goal...

One caveat: do any of your inserting transactions ever fail?  If so, you
need VACUUM to clean up any dead tuples they may have inserted before
failing.

> If it matters, we're currently using Postgres 7.2.1.

You should get yourself to 7.2.4 posthaste, if not 7.3.5 or 7.4.  There
were some really nasty bugs fixed between 7.2.1 and 7.2.4.

            regards, tom lane

pgsql-general by date:

Previous
From: Jenny Zhang
Date:
Subject: Re: deadlock detected when inserting data
Next
From: Tom Lane
Date:
Subject: Re: Relational data model dead?