pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean-Christophe Boggio <cat@thefreecat.org>
To: Postgresql Mailing List <pgsql-sql@postgresql.org>
Subject: Strange DISTINCT !
Date: Mon, 20 Aug 2001 16:51:33 +0200
Message-ID: <15724787382.20010820165133@thefreecat.org> (raw)

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




view thread (3+ messages)  latest in thread

Message-ID: <15724787382.20010820165133@thefreecat.org>
Permalink:  ../15724787382.20010820165133@thefreecat.org/
Also on:    postgresql.org/message-id/15724787382.20010820165133@thefreecat.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: cat@thefreecat.org
  Subject: Re: Strange DISTINCT !
  In-Reply-To: <15724787382.20010820165133@thefreecat.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox