Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 95D26633520 for ; Wed, 4 Aug 2010 15:41:42 -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 28120-08 for ; Wed, 4 Aug 2010 18:41:35 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from serenity.inversion.ee (serenity.inversion.ee [194.204.33.112]) by mail.postgresql.org (Postfix) with ESMTP id 312D3633384 for ; Wed, 4 Aug 2010 15:41:35 -0300 (ADT) Received: by serenity.inversion.ee (Postfix, from userid 108) id 2E86FE34473; Wed, 4 Aug 2010 20:22:47 +0300 (EEST) Received: from [IPv6:::1] (localhost [127.0.0.1]) by serenity.inversion.ee (Postfix) with ESMTP id 956C3E3432C; Wed, 4 Aug 2010 20:22:46 +0300 (EEST) Subject: Re: Questions on query planner, join types, and work_mem From: Hannu Krosing To: Tom Lane Cc: Robert Haas , Peter Hussey , pgsql-performance In-Reply-To: <22961.1280944836@sss.pgh.pa.us> References: <18551.1280275502@sss.pgh.pa.us> <25534.1280498632@sss.pgh.pa.us> <1280819031.14579.38.camel@hvost> <1280944268.3735.12.camel@hvost> <22961.1280944836@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" Date: Wed, 04 Aug 2010 21:41:27 +0300 Message-ID: <1280947287.3735.56.camel@hvost> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 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: 201008/50 X-Sequence-Number: 39893 On Wed, 2010-08-04 at 14:00 -0400, Tom Lane wrote: > 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. Especially the context switch + copy between shared buffers and system disk cache will become noticeable at these speeds. An easy way to test it is loading a table with a few indexes, once with a shared_buffers value, which is senough for only the main table and once with one that fits both table and indexes, > regards, tom lane -- Hannu Krosing http://www.2ndQuadrant.com PostgreSQL Scalability and Availability Services, Consulting and Training