pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frank Lanitz <frank@frank.uvena.de>
To: pgsql-admin@postgresql.org
Subject: Re: Recreate primary key without dropping foreign keys?
Date: Mon, 16 Apr 2012 06:57:17 +0200
Message-ID: <20120416065717.70a31a6361ac5d7bdad416e8@frank.uvena.de> (raw)
In-Reply-To: <4F8B6AA1.1040709@zvelo.com>
References: <4F8B6AA1.1040709@zvelo.com>

On Sun, 15 Apr 2012 18:41:05 -0600
Chris Ernst <cernst@zvelo.com> wrote:

> Hi all,
> 
> In PostgreSQL 9.1.3, I have a few fairly large tables with bloated
> primary key indexes.  I'm trying to replace them using newly created
> unique indexes as outlined in the docs.  Something like:
> 
> CREATE UNIQUE INDEX CONCURRENTLY dist_id_temp_idx ON distributors
> (dist_id); ALTER TABLE distributors DROP CONSTRAINT distributors_pkey,
>     ADD CONSTRAINT distributors_pkey PRIMARY KEY USING INDEX
> dist_id_temp_idx;
> 
> However, the initial drop of the primary key constraint fails because
> there are a whole bunch of foreign keys depending on it.
> 
> I've done some searching and haven't found a workable solution.  Is
> there any way to swap in the new index for the primary key constraint
> without dropping all dependent foreign keys?  Or am I pretty much
> stuck with dropping and recreating all of the foreign keys?

REINDEX is not working here? 

Cheers, 
Frank  
-- 
Frank Lanitz <frank@frank.uvena.de>

view thread (10+ messages)  latest in thread

Message-ID: <20120416065717.70a31a6361ac5d7bdad416e8@frank.uvena.de>
Permalink:  ../20120416065717.70a31a6361ac5d7bdad416e8@frank.uvena.de/
Also on:    postgresql.org/message-id/20120416065717.70a31a6361ac5d7bdad416e8@frank.uvena.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: frank@frank.uvena.de
  Subject: Re: Recreate primary key without dropping foreign keys?
  In-Reply-To: <20120416065717.70a31a6361ac5d7bdad416e8@frank.uvena.de>
  References: <4F8B6AA1.1040709@zvelo.com> <20120416065717.70a31a6361ac5d7bdad416e8@frank.uvena.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox