Re: Is it safe to reset relfrozenxid without using vacuum?

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Arctic Toucan <arctic_toucan(at)hotmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Is it safe to reset relfrozenxid without using vacuum?
Date: 2008-11-18 16:24:06
Message-ID: 20081118162406.GD4141@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Mischa Sandberg 2008-11-18 16:47:24 Re: Reliably determining whether the server came up
Previous Message Tom Lane 2008-11-18 15:59:42 Re: Reliably determining whether the server came up