pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Travis Whitton <tinymountain@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: Grabbing Newest Records From Duplicates
Date: Fri, 16 Mar 2007 10:55:33 -0500
Message-ID: <cf9b4f3e0703160855q537eafe6yf3c3bbea090e5b6e@mail.gmail.com> (raw)
In-Reply-To: <7240.1174059340@sss.pgh.pa.us>
References: <cf9b4f3e0703160828s2cc0b9v6c01db6e8634e37e@mail.gmail.com>
	<7240.1174059340@sss.pgh.pa.us>

One last question, using the "weather report" example, is it going to
improve performance for the DISTINCT ON query to add an index to the
location and time columns?

Thanks a lot,
Travis

On 3/16/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> "Travis Whitton" <tinymountain@gmail.com> writes:
> > Given the following test table, I want to grab only the newest record
> and
> > disregard any older duplicates based on name. Is this the most efficient
> way
> > to do it?
>
> No, it's gonna be pretty awful.  The best way I know of involves
> DISTINCT ON (see the "weather reports" example in the SELECT reference
> page).  Unfortunately that's a Postgres-only construct.  If you want
> something portable then you'll need something messy with subqueries...
>
>                         regards, tom lane
>

view thread (4+ messages)  latest in thread

Message-ID: <cf9b4f3e0703160855q537eafe6yf3c3bbea090e5b6e@mail.gmail.com>
Permalink:  ../cf9b4f3e0703160855q537eafe6yf3c3bbea090e5b6e@mail.gmail.com/
Also on:    postgresql.org/message-id/cf9b4f3e0703160855q537eafe6yf3c3bbea090e5b6e@mail.gmail.com

 · 

reply

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: tinymountain@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: Grabbing Newest Records From Duplicates
  In-Reply-To: <cf9b4f3e0703160855q537eafe6yf3c3bbea090e5b6e@mail.gmail.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