From: Tom Lane <tgl@sss.pgh.pa.us>
To: Claudio Freire <klaussfreire@gmail.com>
Cc: Robert DiFalco <robert.difalco@gmail.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Efficiently query for the most recent record for a given user
Date: Wed, 07 Aug 2013 15:04:09 -0400
Message-ID: <10453.1375902249@sss.pgh.pa.us> (raw)
In-Reply-To: <CAGTBQpZUUOqF6adjmt62Hmc_OYRo3meaoNY9tn93sULRoovO_w@mail.gmail.com>
References: <CAAXGW-yF4urbcPHRj2DwcmkzE66DeJfKQQ+sTmZX-BD_FXKecw@mail.gmail.com>
<CAGTBQpY5pDZBgpo+huLzUpi6zve69V7KKWUVeLaSBpr6ZvOLwQ@mail.gmail.com>
<9813.1375900452@sss.pgh.pa.us>
<CAGTBQpZUUOqF6adjmt62Hmc_OYRo3meaoNY9tn93sULRoovO_w@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
Claudio Freire <klaussfreire@gmail.com> writes:
> On Wed, Aug 7, 2013 at 3:34 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Note that there's no particular need to specify "desc" in the index
>> definition. This same index can support searches in either direction
>> on the "called" column.
> Yeah, but it's faster if it's in the same direction, because the
> kernel read-ahead code detects sequential reads, whereas it doesn't
> when it goes backwards. The difference can be up to a factor of 10 for
> long index scans.
Color me skeptical. Index searches are seldom purely sequential block
accesses. Maybe if you had a freshly built index that'd never yet
suffered any inserts/updates, but in practice any advantage would
disappear very quickly after a few index page splits.
> Though... true... for a limit 1... it wouldn't matter that much.
That's the other point.
regards, tom lane
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
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: tgl@sss.pgh.pa.us, klaussfreire@gmail.com, robert.difalco@gmail.com
Subject: Re: Efficiently query for the most recent record for a given user
In-Reply-To: <10453.1375902249@sss.pgh.pa.us>
* 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