Re: Primary Key

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Joey Quinn <bjquinniii(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Primary Key
Date: 2013-11-22 01:15:30
Message-ID: 528EB032.3090204@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 11/21/2013 12:40 PM, Joey Quinn wrote:
> I have a table (5 columns) with approximately 670 million rows. It has
> had an index (unique) on an inet column from the beginning. Today I
> added a primary key constraint based on the same column thinking that
> since it already had an index, this would be a relatively quick
> operation. That does not appear to be case. It has gone into a "not
> responding" status for an hour or so now. As a point of reference, I'm
> using 9.3 on a 64 bit Windows Server 2008 (32 GB ram) and inserts so far
> have taken 6 1/2 - 7 minutes for each batch of 16.7 million rows.
>
> Other than not creating the primary key at the beginning, did I do
> anything wrong? and can I reasonably expect the current operation to finish?

It will finish but it is checking that not only is it unique, but NOT
NULL. You may want to cancel it and try:

select count(*) from foo where bar IS NULL;

If you have NULL in the column, you don't have a primary key

Joshua D. Drake

>
> Joey
>

--
Command Prompt, Inc. - http://www.commandprompt.com/ 509-416-6579
PostgreSQL Support, Training, Professional Services and Development
High Availability, Oracle Conversion, Postgres-XC, @cmdpromptinc
For my dreams of your image that blossoms
a rose in the deeps of my heart. - W.B. Yeats

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Van Dyk 2013-11-22 02:08:40 Changing function from SECURITY DEFINER to SECURITY INVOKER changes query plan?
Previous Message Tom Lane 2013-11-22 01:12:22 Re: Getting non_NULL right-side values on a non-matching join?