Re: Best way to get the latest revision from a table

From: Nikolas Everett <nik9000(at)gmail(dot)com>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: sthomas(at)peak6(dot)com, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Best way to get the latest revision from a table
Date: 2011-01-15 01:50:02
Message-ID: AANLkTikgQ8y4=5Ly_x+U0mQ7RRHprPGDd-rR8z1NOPWS@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Jan 14, 2011 at 7:59 PM, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov
> wrote:

> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> > Shaun's example is a bit off
>
> > As for speed, either one might be faster in a particular
> > situation.
>
> After fixing a mistake in my testing and learning from Tom's example
> I generated queries against the OP's test data which produce
> identical results, and I'm finding no significant difference between
> run times for the two versions. The OP should definitely try both
> against the real tables.
>
> <snip>

> -Kevin
>

After trying both against the real tables DISTINCT ON seems to be about two
orders of magnitude faster than the other options.

Thanks so much!

Nik Everett

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Craig Ringer 2011-01-15 13:36:44 Re: The good, old times
Previous Message Kevin Grittner 2011-01-15 00:59:50 Re: Best way to get the latest revision from a table