Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 49E4A64FCC7 for ; Tue, 18 Nov 2008 12:24:18 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 03101-02 for ; Tue, 18 Nov 2008 12:24:14 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by mail.postgresql.org (Postfix) with ESMTP id E487464FC8B for ; Tue, 18 Nov 2008 12:24:13 -0400 (AST) Received: from perhan.alvh.no-ip.org (200-126-106-210.bk7-dsl.surnet.cl [200.126.106.210]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id mAIGSiI4029775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 18 Nov 2008 08:28:47 -0800 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id EC73947CC5; Tue, 18 Nov 2008 13:24:06 -0300 (CLST) Date: Tue, 18 Nov 2008 13:24:06 -0300 From: Alvaro Herrera To: Arctic Toucan Cc: pgsql-admin@postgresql.org Subject: Re: Is it safe to reset relfrozenxid without using vacuum? Message-ID: <20081118162406.GD4141@alvh.no-ip.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Tue, 18 Nov 2008 08:28:47 -0800 (PST) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/99 X-Sequence-Number: 30753 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 = ' 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