Strange DISTINCT ! - Mailing list pgsql-sql

From Jean-Christophe Boggio
Subject Strange DISTINCT !
Date
Msg-id 15724787382.20010820165133@thefreecat.org
Whole thread Raw
Responses Re: Strange DISTINCT !  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List 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@thefreecat.org                           -o)
Independant Consultant and Developer         /\\
Delphi, Linux, Perl, PostgreSQL             _\_V



pgsql-sql by date:

Previous
From: Mark Mikulec
Date:
Subject: Sequential select queries...??
Next
From: fimbulvetr@lycos.com (fimbulvetr)
Date:
Subject: Re: `postgresql.conf' has wrong permissions???