Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 9875FB5DBD1 for ; Mon, 13 Jun 2011 02:48:01 -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 79422-07 for ; Mon, 13 Jun 2011 05:47:54 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iy0-f174.google.com (mail-iy0-f174.google.com [209.85.210.174]) by mail.postgresql.org (Postfix) with ESMTP id 3034CB5DBC6 for ; Mon, 13 Jun 2011 02:47:53 -0300 (ADT) Received: by iyb14 with SMTP id 14so3580898iyb.19 for ; Sun, 12 Jun 2011 22:47:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.42.228.133 with SMTP id je5mr6408867icb.107.1307944071555; Sun, 12 Jun 2011 22:47:51 -0700 (PDT) Received: by 10.42.220.198 with HTTP; Sun, 12 Jun 2011 22:47:51 -0700 (PDT) In-Reply-To: <35505.8950.qm@web26008.mail.ukl.yahoo.com> References: <35505.8950.qm@web26008.mail.ukl.yahoo.com> Date: Mon, 13 Jun 2011 12:47:51 +0700 Message-ID: Subject: Re: Reindexing primary keys without locking From: Stuart Bishop To: Glyn Astill Cc: "pgsql-admin@postgresql.org" Content-Type: text/plain; charset=UTF-8 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/55 X-Sequence-Number: 37681 On Wed, Jun 1, 2011 at 7:38 PM, Glyn Astill wrote: > Hi Guys, > Does anyone know of any tricks to replace primary key indexes without using > reindex? Or any other method that will not lock the table for an extended > 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/PrimaryKeyTransplant 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 Bishop http://www.stuartbishop.net/