Strange DISTINCT !

From: Jean-Christophe Boggio <cat(at)thefreecat(dot)org>
To: Postgresql Mailing List <pgsql-sql(at)postgresql(dot)org>
Subject: Strange DISTINCT !
Date: 2001-08-20 14:51:33
Message-ID: 15724787382.20010820165133@thefreecat.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello, can someone explain to me why this query is so slow :

select distinct t.idmembre,p.datecrea
from tmp_stat t,prefs p
where p.idmembre=t.idmembre
limit 5;

And this one is so fast :

select t.idmembre,p.datecrea
from (select distinct idmembre from tmp_stat) as t,
prefs p
where p.idmembre=t.idmembre
limit 5;

(I currently have idmembre as an index on tmp_stat and prefs)

How does DISTINCT work ? Is this a bug or a misconfigured index ?

--
Jean-Christophe Boggio
cat(at)thefreecat(dot)org -o)
Independant Consultant and Developer /\\
Delphi, Linux, Perl, PostgreSQL _\_V

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Robby Slaughter 2001-08-20 14:55:47 RE: Simple SQL-syntax
Previous Message Jeff Eckermann 2001-08-20 14:29:21 Re: Simple SQL-syntax