Re: What does count(*) count? - Mailing list pgsql-general

From Bruce Momjian
Subject Re: What does count(*) count?
Date
Msg-id 200312311737.hBVHbqG15935@candle.pha.pa.us
Whole thread Raw
In response to Re: What does count(*) count?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Tom Lane wrote:
> =?iso-8859-1?Q?Egy=FCd_Csaba?= <csegyud@vnet.hu> writes:
> > I've got it, but I don't know the reason of it.
> > In the database table the records have duplicated and I've two rows for
> > every primary key - with different OIDs.
>
> Sure sounds like a child table to me.
>
> > Is there any safe method to get rid of only one of each duplicated row?
>
> Drop the child table.

This does illustrate an unusual case where a unique index does not
guarantee unique rows from a table:

    test=> CREATE TABLE t1 (x INT);
    CREATE TABLE
    test=> CREATE UNIQUE INDEX ii ON t1(x);
    CREATE INDEX
    test=> CREATE TABLE t2 (y INT) inherits (t1);
    CREATE TABLE
    test=> INSERT INTO t1 VALUES (1);
    INSERT 17389 1
    test=> INSERT INTO t2 VALUES (1,2);
    INSERT 17390 1
    test=> SELECT * FROM t1;
     x
    ---
     1
     1
    (2 rows)

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-general by date:

Previous
From:
Date:
Subject: Re: Is my MySQL Gaining ?
Next
From: Eric Ridge
Date:
Subject: Re: website doc search is extremely SLOW