Re: Picking out the most recent row using a time stamp column

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Shaun Thomas <sthomas(at)peak6(dot)com>
Cc: Dave Crooke <dcrooke(at)gmail(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Michael Glaesemann <grzm(at)seespotcode(dot)net>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Picking out the most recent row using a time stamp column
Date: 2011-02-25 01:52:19
Message-ID: 4D670B53.70003@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


> Why did you use row_number instead of rank?

Because I assumed he only wanted one row in the event of ties.

Hmmm, although with that schema, there won't be ties. So it's pretty
much arbitrary then.

> I am now curious how the speed compares though. I still think the
> DISTINCT ON will be faster, but it would be a great surprise.

Hopefully we'll find out! The windowing functions are usually much
faster for me. I think in 9.0 or 9.1 someone replumbed DISTINCT ON to
use a bunch of the window function internals, at which point it'll cease
to matter.

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Sam Wong 2011-02-25 03:02:23 Perl Binding affects speed?
Previous Message Shaun Thomas 2011-02-25 00:58:33 Re: Picking out the most recent row using a time stamp column