From: | Wei Weng <wweng(at)kencast(dot)com> |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: How slow is DISTINCT? |
Date: | 2002-02-27 22:57:46 |
Message-ID: | 3C7D646A.8070804@kencast.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Josh Berkus wrote:
> Wei Wang,
>
>
>>How exactly slow is DISTINCT being processed in SQL engines? (not
>>limited to postgresql, though comments on postgresql would be most
>> relevant)
>>
>
> I can only give you a relative result, based exlusively on my anecdotal
> experience with 7.1:
>
> Fast: SELECT ...
> Slower: SELECT ... GROUP BY x,y,z
> or: SELECT DISCTINCT ON (x) ... (Postgres non-standard extension)
> SLowest: SELECT DISTINCT ...
>
> The reason for this is that SELECT DISTINCT is effectively a GROUP BY
> on all result fields of the query, and if a few of the aren't indexed
> that requires a seq scan.
What if I do thing like
SELECT DISTINCT table1.tid, table1.name, table1.description FROM ...
Does it equal to the scenario 2 or 3?
I am thinking SELECT DISTINCT table1.tid is just a variation (or the
other way around) of SELECT DISTINCT ON (table1.tid), is that right?
Thanks
--
Wei Weng
Network Software Engineer
KenCast Inc.
From | Date | Subject | |
---|---|---|---|
Next Message | Wei Weng | 2002-02-27 23:20:22 | Re: How slow is DISTINCT? |
Previous Message | Josh Berkus | 2002-02-27 22:54:39 | Re: How slow is DISTINCT? |