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

From: Shaun Thomas <sthomas(at)peak6(dot)com>
To: Nikolas Everett <nik9000(at)gmail(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: "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 19:58:45
Message-ID: D247E79EFD801E40A9449A9724F6295B4C5F5F4F@spswchi6mail1.peak6.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


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

Glad it worked. It looked at least naively similar to situations I've run into and DISTINCT ON always helped me out. It's all the fun of GROUP BY with the ability to discard non-aggregate results just by screwing around with your sorting. Still one of my favorite tricks.

--
Shaun Thomas
Peak6 | 141 W. Jackson Blvd. | Suite 800 | Chicago, IL 60604
312-676-8870
sthomas(at)peak6(dot)com

______________________________________________

See http://www.peak6.com/email_disclaimer.php
for terms and conditions related to this email

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Craig Ringer 2011-01-16 06:50:51 Re: The good, old times
Previous Message Shaun Thomas 2011-01-15 19:54:29 Re: Best way to get the latest revision from a table