Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 6FD611337B39 for ; Tue, 21 Sep 2010 16:34:50 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 56314-01 for ; Tue, 21 Sep 2010 19:34:44 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mxout-07.mxes.net (mxout-07.mxes.net [216.86.168.182]) by mail.postgresql.org (Postfix) with ESMTP id 242951337B2A for ; Tue, 21 Sep 2010 16:34:43 -0300 (ADT) Received: from [192.168.1.104] (unknown [173.165.13.38]) by smtp.mxes.net (Postfix) with ESMTPA id EA6D722E25A; Tue, 21 Sep 2010 15:34:42 -0400 (EDT) Subject: Re: Query much faster with enable_seqscan=0 Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii From: Ogden In-Reply-To: <4C9904A9.5080301@2ndquadrant.com> Date: Tue, 21 Sep 2010 14:34:42 -0500 Cc: pgsql-performance@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: 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> To: Greg Smith X-Mailer: Apple Mail (2.1081) 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: 201009/132 X-Sequence-Number: 40335 On Sep 21, 2010, at 2:16 PM, Greg Smith wrote: > Joshua D. Drake wrote: >> PostgreSQL's defaults are based on extremely small and some would say >> (non production) size databases. As a matter of course I always >> recommend bringing seq_page_cost and random_page_cost more in line. >> =20 >=20 > Also, they presume that not all of your data is going to be in memory, = 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. >=20 I have done just that, per your recommendations and now what took 14 = seconds, only takes less than a second, so it was certainly these = figures I messed around with. I have set: seq_page_cost =3D 0.01 =20 random_page_cost =3D 0.02 =20 cpu_tuple_cost =3D 0.01 Everything seems to run faster now. I think this should be fine - I'll = keep an eye on things over the next few days.=20 I truly appreciate everyone's help.=20 Ogden