Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-admin by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group