Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id DE53C63356F for ; Thu, 7 Jan 2010 14:14:25 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 98938-07 for ; Thu, 7 Jan 2010 18:14:13 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id B632C633B75 for ; Thu, 7 Jan 2010 14:14:14 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.3/8.14.3) with ESMTP id o07IEDtG062323 for ; Thu, 7 Jan 2010 14:14:13 -0400 (AST) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.3/8.14.3/Submit) id o07Htv9O054664 for pgsql-performance@postgresql.org; Thu, 7 Jan 2010 13:55:57 -0400 (AST) (envelope-from news) From: "Carlo Stonebanks" X-Newsgroups: pgsql.performance Subject: Re: Massive table (500M rows) update nightmare Date: Thu, 7 Jan 2010 12:56:37 -0500 Organization: Hub.Org Networking Services Lines: 29 Message-ID: References: <4B45DE4C.4050606@beecom.ch> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org In-Reply-To: <4B45DE4C.4050606@beecom.ch> X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6002.18005 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18005 To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.002 tagged_above=-10 required=5 tests=BAYES_50=0.001, STOX_REPLY_TYPE=0.001 X-Spam-Level: X-Archive-Number: 201001/116 X-Sequence-Number: 36996 > If it is possible to lock this audit table exclusively (may be during > off peak hours) I would look into > - create new_audit_table as select col1, col2, col3 ... col9, > 'new_col_value' from old_audit_table; > - create all indexes > - drop old_audit_table > - rename new_audit_table to old_audit_table > > That is probably the fasted method you can do, even if you have to join > the "new_col_value" from an extra helper-table with the correspondig id. > Remeber, databases are born to join. > This has all been done before - the production team was crippled while they waited for this and the SECOND the table was available again, they jumped on it - even though it meant recreating the bare minimum of the indexes. > You could also try to just update the whole table in one go, it is > probably faster than you expect. Possibly, but with such a large table you have no idea of the progress, you cannot interrupt it without rolling back everything. Worse, you have applications stalling and users wanting to know what is going on - is the OS and the DB/MVCC trashing while it does internal maintenance? Have you reached some sort of deadlock condition that you can't see because the server status is not helpful with so many uncommitted pending updates? And of course, there is the file bloat.