Re: Is it safe to reset relfrozenxid without using vacuum? - Mailing list pgsql-admin

From Alvaro Herrera
Subject Re: Is it safe to reset relfrozenxid without using vacuum?
Date
Msg-id 20081118162406.GD4141@alvh.no-ip.org
Whole thread Raw
In response to Is it safe to reset relfrozenxid without using vacuum?  (Arctic Toucan <arctic_toucan@hotmail.com>)
Responses Re: Is it safe to reset relfrozenxid without using vacuum?
List pgsql-admin
Arctic Toucan wrote:
>
> I have a heavily partitioned DW type database that has over 5,000
> tables in it. Data is only ever inserted, read and then truncated
> after some period of time. Once the table is truncated, the
> constraints are changed and the table is reused. This works well until
> Postgres hits the autovacuum_freeze_max_age, which I currently have
> set @ 1billion). Since these tables are only ever inserted to and
> truncated, they are not normally vacuumed(which is what I want, since
> data is typically going to be truncated before needing to be
> vacuumed).

AFAICS this should be safe.  In fact, in 8.3 TRUNCATE advances
relfrozenxid.  (Perhaps you should consider upgrading if possible.)


> UPDATE pg_class SET relfrozenxid = ( select relfrozenxid from pg_class
> where age(relfrozenxid) in (select min(age(relfrozenxid)) from
> pg_class where relkind = 'r') limit 1) WHERE relname = '<table being
> truncated>';

Tou could just obtain the xid of the transaction that's going to do the
import (for example by creating a temp table and getting it's xmin from
pg_class)

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: Reliably determining whether the server came up
Next
From: Mischa Sandberg
Date:
Subject: Re: Reliably determining whether the server came up