Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 79778B5DBBE for ; Mon, 13 Jun 2011 04:54:54 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 38531-10 for ; Mon, 13 Jun 2011 07:54:47 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail148112.authsmtp.co.uk (outmail148112.authsmtp.co.uk [62.13.148.112]) by mail.postgresql.org (Postfix) with ESMTP id E3CE2B5D80A for ; Mon, 13 Jun 2011 04:54:46 -0300 (ADT) Received: from mail-c193.authsmtp.com (mail-c193.authsmtp.com [62.13.128.118]) by punt9.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id p5D7sjmZ033004 for ; Mon, 13 Jun 2011 08:54:45 +0100 (BST) Received: from mail-qy0-f174.google.com (mail-qy0-f174.google.com [209.85.216.174]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2) with ESMTP id p5D7sgxw098959 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Mon, 13 Jun 2011 08:54:43 +0100 (BST) Received: by qyk7 with SMTP id 7so715657qyk.19 for ; Mon, 13 Jun 2011 00:54:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.88.198 with SMTP id b6mr3538090qcm.208.1307951682212; Mon, 13 Jun 2011 00:54:42 -0700 (PDT) Received: by 10.229.32.197 with HTTP; Mon, 13 Jun 2011 00:54:42 -0700 (PDT) In-Reply-To: References: <35505.8950.qm@web26008.mail.ukl.yahoo.com> Date: Mon, 13 Jun 2011 08:54:42 +0100 Message-ID: Subject: Re: Reindexing primary keys without locking From: Simon Riggs To: Stuart Bishop Cc: Glyn Astill , "pgsql-admin@postgresql.org" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Server-Quench: 664ca01d-9592-11e0-97bb-002264978518 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZOTQEd DAteCiN5VAwpPBRK HVkIKg5MOFUSTAAU O0pfL1x7KFoHWV5D ViVKB0oLEgo/WGBq EU8PcgddY0teXw1g VUxDRlEcFgVhHxQE GBwfVAdzcAFZfXZ3 ekcsHnUvWwctPQF9 S0ZdEGRIYWJnYC4Z VkQLJgNVJB5DexZH d1F+AXMQaGJVNGdg R1VpYWxgYmUCcXRD eAxfZWE7bWMqOAt0 fR0DGzkiDUwDSG0r NR0jI0QNVEUcI156 Llo9WVUFL1cWDQZd HkdCaKAQ X-Authentic-SMTP: 61633235383639.1014:706 X-AuthFastPath: 0 (Was 255) X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/56 X-Sequence-Number: 37682 On Mon, Jun 13, 2011 at 6:47 AM, Stuart Bishop wr= ote: > On Wed, Jun 1, 2011 at 7:38 PM, Glyn Astill wrot= e: >> Hi Guys, >> Does anyone know of any tricks to replace primary key indexes without us= ing >> reindex? Or any other method that will not lock the table for an extende= d >> amount of time on 8.4? >> I've got a bloated primary key index on a table and I'd like to try and >> clean it up without downtime. > > If you are brave, http://pqxx.org/development/libpqxx/wiki/PrimaryKeyTran= splant > > If you go this route, ensure you have a test environment and ensure > you can dump and restore your db schema after applying the patch, and > that the diff of the before and after schemas checks out. If you screw > up, you can end up with crazy things like multiple indexes with the > same name and other stuff making your database unrecoverable. Stuart, That looks interesting. There's a similar process in the PostgreSQL Admin Cookbook, though our work was independent. I guess that's because in 9.0 and below it really is the only way to make it work correctly. Will look for your work in future, thanks. --=20 =A0Simon Riggs=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 http:/= /www.2ndQuadrant.com/ =A0PostgreSQL Development, 24x7 Support, Training & Services