Re: Problem with phone list.

From: "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar>
To: "'Michael Glaesemann'" <grzm(at)seespotcode(dot)net>, "'Mike Diehl'" <jdiehl(at)sandia(dot)gov>
Cc: "'SQL Postgresql List'" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Problem with phone list.
Date: 2007-08-16 13:56:17
Message-ID: 022401c7e00d$379dbeb0$8f01010a@iptel.com.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

--- Michael Glaesemann wrote:

> SELECT DISTINCT ON (phone_number)
> phone_number, call_duration, id
> FROM calls
> ORDER BY phone_number
> , call_duration DESC;

Wasn't acquainted with "DISTINCT ON (column)".
I found it to be many times faster than other suggestions using JOIN.

Cheers,
Fernando.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Glaesemann 2007-08-16 15:35:13 Re: SUPERUSER vs CREATEUSER causes foul 'code smell'
Previous Message Alvaro Herrera 2007-08-16 13:28:15 Re: Starting autovacuum in postgresql-8.1.9