Re: How slow is DISTINCT? - Mailing list pgsql-sql

From Josh Berkus
Subject Re: How slow is DISTINCT?
Date
Msg-id web-812221@davinci.ethosmedia.com
Whole thread Raw
In response to Re: How slow is DISTINCT?  (Wei Weng <wweng@kencast.com>)
List pgsql-sql
Wei,

> SELECT DISTINCT table1.tid, table1.name, table1.description FROM ...
> 
> Does it equal to the scenario 2 or 3?

Three.

> 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?

Wrong.  SELECT DISTINCT ON table1.tid takes the table1.tid field andthe first related other data it can find.  SELECT
DISTINCTlooks forthe unique combinaiton of all fields selected.  In a multi-table, manyfield query, the former is
fasterthan the latter bceause less data isbeing checked for uniqueness, and extra data is simply discarded.
 

Tom, please correct me if I'm totally out on a limb, here.

-Josh

______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco
 


pgsql-sql by date:

Previous
From: Wei Weng
Date:
Subject: Re: How slow is DISTINCT?
Next
From: Wei Weng
Date:
Subject: Re: How slow is DISTINCT?