Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id CBBB2B5D802 for ; Sun, 15 May 2011 17:32:10 -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 14622-07 for ; Sun, 15 May 2011 20:32:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gx0-f174.google.com (mail-gx0-f174.google.com [209.85.161.174]) by mail.postgresql.org (Postfix) with ESMTP id 8E1D4B5D800 for ; Sun, 15 May 2011 17:32:02 -0300 (ADT) Received: by gxk21 with SMTP id 21so1335766gxk.19 for ; Sun, 15 May 2011 13:32:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=6mQ8WVviTP520i/JRS1idCbsToAD9fky9KoxlmNUjzE=; b=ILzJRqgBmwmez2gIzNGRM0kNhTI8y54YBDSk0J2SBWUqO+nPFMgGmX+LS7kKPkftcO Lvsvt2JEi22Rim37Ewo55x1kOOEmFT2+S6fUNU4FRY3tQSayXDIrr3hhgVSoDjSi13oS /GcBw8QWZ3z2Pv0PBy1bqVSpWzEsFLFGNwuSA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=h+G5BCylN/A6fCQn07IAN900imw9gyJF264Fwk9C3nh6RsGrzvIUoclfrF2ATAMn7Y QEOXwF56ZvuGZVesnELQ7bU/15GMVJVeOflZDv8il09ZqJ8wAwgcXFGqNlYHEMLAo1bd BP4h7wIc/mWyU5TFuylV1mUmH9nSMmqWJz6ww= MIME-Version: 1.0 Received: by 10.236.108.177 with SMTP id q37mr3720899yhg.14.1305491522177; Sun, 15 May 2011 13:32:02 -0700 (PDT) Received: by 10.236.110.41 with HTTP; Sun, 15 May 2011 13:32:01 -0700 (PDT) In-Reply-To: <4DD016B5.2080202@agliodbs.com> References: <4DB6F4BB020000250003CEB9@gw.wicourts.gov> <2823.1305314437@sss.pgh.pa.us> <4DCD90F5.2010501@agliodbs.com> <4DD016B5.2080202@agliodbs.com> Date: Sun, 15 May 2011 16:32:01 -0400 Message-ID: Subject: Re: reducing random_page_cost from 4 to 2 to force index scan From: Robert Haas To: Josh Berkus Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201105/223 X-Sequence-Number: 43732 On Sun, May 15, 2011 at 2:08 PM, Josh Berkus wrote: >> All true. =A0I 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. =A0In fact, there's good reason to suppose that, if you were selectin= g > 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. =A0They > 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. Well, anything's possible. But I wonder whether the effects you are describing might result from a reduction in the *number* of pages accessed rather than a change in the access pattern. --=20 Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company