Re: Tuning queries and distinct behaviour

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gordan Bobic" <gordan(at)freeuk(dot)com>
Cc: "PostgreSQL General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Tuning queries and distinct behaviour
Date: 2001-01-18 21:33:22
Message-ID: 5286.979853602@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Gordan Bobic" <gordan(at)freeuk(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adam Lang 2001-01-18 21:37:07 Re: Re: MS Access data to PostgrSQL data
Previous Message Tom Lane 2001-01-18 21:30:09 Re: Another optimizer question