Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V791r-0004O7-UA for pgsql-performance@arkaria.postgresql.org; Wed, 07 Aug 2013 19:04:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V791r-0004Hz-Dk for pgsql-performance@arkaria.postgresql.org; Wed, 07 Aug 2013 19:04:15 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V791q-0004Ht-JB for pgsql-performance@postgresql.org; Wed, 07 Aug 2013 19:04:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V791m-00019F-IQ for pgsql-performance@postgresql.org; Wed, 07 Aug 2013 19:04:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id r77J49Wr010454; Wed, 7 Aug 2013 15:04:09 -0400 From: Tom Lane To: Claudio Freire cc: Robert DiFalco , "pgsql-performance@postgresql.org" Subject: Re: Efficiently query for the most recent record for a given user In-reply-to: References: <9813.1375900452@sss.pgh.pa.us> Comments: In-reply-to Claudio Freire message dated "Wed, 07 Aug 2013 15:39:45 -0300" Date: Wed, 07 Aug 2013 15:04:09 -0400 Message-ID: <10453.1375902249@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Claudio Freire writes: > On Wed, Aug 7, 2013 at 3:34 PM, Tom Lane 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