Received: from miaou.thefreecat.org ([213.11.8.225]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f7KEq9P43639 for ; Mon, 20 Aug 2001 10:52:09 -0400 (EDT) (envelope-from cat@thefreecat.org) Received: from bast (bast.thefreecat.local [192.168.0.2]) by miaou.thefreecat.org (Postfix) with ESMTP id C7C229295B for ; Mon, 20 Aug 2001 16:52:04 +0200 (CEST) Date: Mon, 20 Aug 2001 16:51:33 +0200 From: Jean-Christophe Boggio X-Mailer: The Bat! (v1.53bis) Personal Reply-To: Jean-Christophe Boggio X-Priority: 3 (Normal) Message-ID: <15724787382.20010820165133@thefreecat.org> To: Postgresql Mailing List Subject: Strange DISTINCT ! MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200108/242 X-Sequence-Number: 4476 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