Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 2D8EC1337B2F for ; Tue, 21 Sep 2010 20:25:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 56971-05 for ; Tue, 21 Sep 2010 23:25:05 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id E0FEB1336B42 for ; Tue, 21 Sep 2010 20:25:04 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o8LNOltB011633; Tue, 21 Sep 2010 19:24:48 -0400 (EDT) To: Greg Smith cc: jd@commandprompt.com, Ogden , Jesper Krogh , Kenneth Marshall , pgsql-performance@postgresql.org Subject: Re: Query much faster with enable_seqscan=0 In-reply-to: <4C9904A9.5080301@2ndquadrant.com> References: <0D5B9ED0-00C3-4EEB-8336-0B2F8A884620@darkstatic.com> <20100921180618.GI17152@aart.is.rice.edu> <4C98FEA2.8030607@krogh.cc> <3062DF4E-7460-4487-818A-BF77F176E501@darkstatic.com> <1285096031.15919.68.camel@jd-desktop.unknown.charter.com> <4C9904A9.5080301@2ndquadrant.com> Comments: In-reply-to Greg Smith message dated "Tue, 21 Sep 2010 15:16:57 -0400" Date: Tue, 21 Sep 2010 19:24:47 -0400 Message-ID: <11632.1285111487@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201009/137 X-Sequence-Number: 40340 Greg Smith writes: > and the query optimizer needs to be careful about what it does and > doesn't pull from disk. If that's not the case, like here where there's > 8GB of RAM and a 7GB database, dramatic reductions to both seq_page_cost > and random_page_cost can make sense. Don't be afraid to think lowering > below 1.0 is going too far--something more like 0.01 for sequential and > 0.02 for random may actually reflect reality here. If you are tuning for an all-in-RAM situation, you should set random_page_cost equal to seq_page_cost (and usually set both smaller than 1). By definition, those costs are equal if you're fetching from RAM. If it's only mostly-in-RAM then keeping random_page_cost a bit higher makes sense. regards, tom lane