From: Josh Berkus <josh@agliodbs.com>
To: Shaun Thomas <sthomas@peak6.com>
Cc: Dave Crooke <dcrooke@gmail.com>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: Michael Glaesemann <grzm@seespotcode.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: Picking out the most recent row using a time stamp column
Date: Thu, 24 Feb 2011 17:52:19 -0800
Message-ID: <4D670B53.70003@agliodbs.com> (raw)
In-Reply-To: <4D66FEB9.6000501@peak6.com>
References: <AANLkTinTgU-jfPOhrfteBvhAhgG_8zknpk13N9L4QMap@mail.gmail.com>
<08B3368E-E623-4E9C-83F5-AB05B471AF4C@seespotcode.net>
<4D666A0F020000250003AFCE@gw.wicourts.gov>
<AANLkTimSmjGrCqwZWRXU1_=FW0adbWdxLXMK0n=Vw+Cc@mail.gmail.com>
<4D66F5B0.5080502@agliodbs.com>
<4D66FEB9.6000501@peak6.com>
> 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
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-performance@postgresql.org
Cc: josh@agliodbs.com, sthomas@peak6.com, dcrooke@gmail.com, Kevin.Grittner@wicourts.gov, grzm@seespotcode.net
Subject: Re: Picking out the most recent row using a time stamp column
In-Reply-To: <4D670B53.70003@agliodbs.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