Re: how could duplicate pkey exist in psql?

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Yan Chunlu <springrider(at)gmail(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: how could duplicate pkey exist in psql?
Date: 2011-11-17 12:28:24
Message-ID: 20111117122824.GD7623@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Nov 17, 2011 at 01:19:30PM +0800, Yan Chunlu wrote:
> recently I have found several tables has exactly the same pkey, here is
> the definition:
> "diggcontent_data_account_pkey" PRIMARY KEY, btree (thing_id, key)

please check:
select thing_id, key, count(*) from diggcontent_data_account group by 1,2 having
count(*) > 1;

this will show if you have really duplicated values.

if you have - the index ( diggcontent_data_account_pkey ) is broken.
Exact reason can vary, any chance this database is hot-backup restored
from different system?

Best regards,

depesz

--
The best thing about modern society is how easy it is to avoid contact with it.
http://depesz.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Anibal David Acosta 2011-11-17 12:48:10 checkpoints are occurring too frequently
Previous Message hubert depesz lubaczewski 2011-11-17 12:15:39 Re: How could I find the last modified procedure in the database?