Re: Tuning queries and distinct behaviour - Mailing list pgsql-general

From Tom Lane
Subject Re: Tuning queries and distinct behaviour
Date
Msg-id 5286.979853602@sss.pgh.pa.us
Whole thread Raw
In response to Tuning queries and distinct behaviour  ("Gordan Bobic" <gordan@freeuk.com>)
List pgsql-general
"Gordan Bobic" <gordan@freeuk.com> writes:
> It just seems a bit strange
> that doing subqueries with temporary tables should be so much faster.

Hard to respond to this complaint without a specific example.

> SELECT DISTINCT ON (Table1.Field3) * FROM SomeView. I would hope that
> DISTINCT would pick the first record returned for each of the different
> occurences in SomeView.

It does, but kindly notice that you have not constrained what the first
record returned is.  See the example of SELECT DISTINCT ON usage in the
SELECT reference page,
http://www.postgresql.org/users-lounge/docs/7.0/postgres/sql-select.htm

            regards, tom lane

pgsql-general by date:

Previous
From: "Adam Lang"
Date:
Subject: Re: Re: MS Access data to PostgrSQL data
Next
From: Chris Hayner
Date:
Subject: mSQL to PgSQL