Re: DISTINCT is not quite distinct

From: Richard Huxton <dev(at)archonet(dot)com>
To: Florian Weimer <fweimer(at)bfk(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: DISTINCT is not quite distinct
Date: 2006-11-06 14:34:31
Message-ID: 454F47F7.6090108@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Florian Weimer wrote:
> I run this innocent query
>
> CREATE TABLE foo AS SELECT DISTINCT bar FROM baz ORDER BY bar;
>
> and the resulting table contains duplicate rows. 8-(
>
> According to EXPLAIN, an index scan on the bar column is used (using
> the underlying B-tree index). This is with PostgreSQL 8.1.4 (Debian
> package 8.1.4-6). Is this a known problem?
>
> If I drop the DISTINCT, the output is not correctly ordered, either.
> Perhaps this is an index corruption issue? The hardware itself seems
> fine.

Could be index corruption perhaps.

I take it SELECT DISTINCT bar... shows the same problem?

If so, can you do:
SELECT OID,xmin,cmin,xmax,cmax,bar FROM baz
WHERE bar = <something with duplicates>

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-11-06 14:42:03 Re: DISTINCT is not quite distinct
Previous Message Merlin Moncure 2006-11-06 14:31:02 Re: select result / functions from another database in plpgsql