Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 2C7A36325EE for ; Wed, 4 Aug 2010 15:00: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 10542-09 for ; Wed, 4 Aug 2010 18:00:42 +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 B8946632406 for ; Wed, 4 Aug 2010 15:00:42 -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 o74I0arh022962; Wed, 4 Aug 2010 14:00:36 -0400 (EDT) To: Hannu Krosing cc: Robert Haas , Peter Hussey , pgsql-performance Subject: Re: Questions on query planner, join types, and work_mem In-reply-to: <1280944268.3735.12.camel@hvost> References: <18551.1280275502@sss.pgh.pa.us> <25534.1280498632@sss.pgh.pa.us> <1280819031.14579.38.camel@hvost> <1280944268.3735.12.camel@hvost> Comments: In-reply-to Hannu Krosing message dated "Wed, 04 Aug 2010 20:51:08 +0300" Date: Wed, 04 Aug 2010 14:00:36 -0400 Message-ID: <22961.1280944836@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: 201008/49 X-Sequence-Number: 39892 Hannu Krosing writes: > Of course there are more variables than just *_page_cost, so if you nail > down any other one, you may end with less than 1 for both page costs. > I have always used seq_page_cost = 1 in my thinking and adjusted others > relative to it. Right, seq_page_cost = 1 is sort of the traditional reference point, but you don't have to do it that way. The main point here is that for an all-in-RAM database, the standard page access costs are too high relative to the CPU effort costs: regression=# select name, setting from pg_settings where name like '%cost'; name | setting ----------------------+--------- cpu_index_tuple_cost | 0.005 cpu_operator_cost | 0.0025 cpu_tuple_cost | 0.01 random_page_cost | 4 seq_page_cost | 1 (5 rows) To model an all-in-RAM database, you can either dial down both random_page_cost and seq_page_cost to 0.1 or so, or set random_page_cost to 1 and increase all the CPU costs. The former is less effort ;-) It should be noted also that there's not all that much evidence backing up the default values of the cpu_xxx_cost variables. In the past those didn't matter much because I/O costs always swamped CPU costs anyway. But I can foresee us having to twiddle those defaults and maybe refine the CPU cost model more, as all-in-RAM cases get more common. regards, tom lane