From: Josh Berkus <josh@agliodbs.com>
To: wweng@kencast.com, Josh Berkus <josh@agliodbs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: How slow is DISTINCT?
Date: Wed, 27 Feb 2002 14:54:39 -0800
Message-ID: <web-812221@davinci.ethosmedia.com> (raw)
In-Reply-To: <3C7D646A.8070804@kencast.com>
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 and
the first related other data it can find. SELECT DISTINCT looks for
the unique combinaiton of all fields selected. In a multi-table, many
field query, the former is faster than the latter bceause less data is
being 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 information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
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: josh@agliodbs.com
Subject: Re: How slow is DISTINCT?
In-Reply-To: <web-812221@davinci.ethosmedia.com>
* 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