Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id DB8F7B5DBBE for ; Sun, 15 May 2011 15:08:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 69589-02 for ; Sun, 15 May 2011 18:08:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-2.01.com (smtp-2.01.com [38.102.63.181]) by mail.postgresql.org (Postfix) with ESMTP id 65FB8B5DBC0 for ; Sun, 15 May 2011 15:08:50 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp-2.01.com (Postfix) with ESMTP id 2B9431ADEEF; Sun, 15 May 2011 13:08:50 -0500 (CDT) Received: from smtp-2.01.com ([127.0.0.1]) by localhost (smtp-2.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WJWm8XAwOIx3; Sun, 15 May 2011 13:08:50 -0500 (CDT) Received: by smtp-2.01.com (Postfix, from userid 99) id 0F8FC1ADF1D; Sun, 15 May 2011 13:08:50 -0500 (CDT) Received: from Sidney-Stratton.local (70-36-197-225.dsl.dynamic.sonic.net [70.36.197.225]) by smtp-2.01.com (Postfix) with ESMTPSA id ACE661ADEEF; Sun, 15 May 2011 13:08:49 -0500 (CDT) Message-ID: <4DD016B5.2080202@agliodbs.com> Date: Sun, 15 May 2011 11:08:53 -0700 From: Josh Berkus Organization: PostgreSQL Experts Inc. User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: Robert Haas CC: pgsql-performance@postgresql.org Subject: Re: reducing random_page_cost from 4 to 2 to force index scan References: <4DB6F4BB020000250003CEB9@gw.wicourts.gov> <2823.1305314437@sss.pgh.pa.us> <4DCD90F5.2010501@agliodbs.com> In-Reply-To: X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201105/221 X-Sequence-Number: 43730 Robert, > All true. I suspect that in practice the different between random and > sequential memory page costs is small enough to be ignorable, although > of course I might be wrong. This hasn't been my experience, although I have not carefully measured it. In fact, there's good reason to suppose that, if you were selecting 50% of more of a table, sequential access would still be faster even for an entirely in-memory table. As a parallel to our development, Redis used to store all data as linked lists, making every object lookup effectively a random lookup. They found that even with a database which is pinned in memory, creating a data page structure (they call it "ziplists") and supporting sequential scans was up to 10X faster for large lists. So I would assume that there is still a coefficient difference between seeks and scans in memory until proven otherwise. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com