Re: What does count(*) count?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: csegyud(at)vnet(dot)hu, "'Reid Thompson'" <Reid(dot)Thompson(at)ateb(dot)com>, "Pgsql-General(at)Postgresql(dot)Org (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: What does count(*) count?
Date: 2003-12-31 17:37:52
Message-ID: 200312311737.hBVHbqG15935@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> =?iso-8859-1?Q?Egy=FCd_Csaba?= <csegyud(at)vnet(dot)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(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Eric Ridge 2003-12-31 18:03:47 Re: website doc search is extremely SLOW
Previous Message terry 2003-12-31 17:29:14 Re: Is my MySQL Gaining ?