X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3CCCA52960 for ; Mon, 23 May 2005 17:50:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07591-03 for ; Mon, 23 May 2005 20:50:16 +0000 (GMT) Received: from cmailm2.svr.pol.co.uk (cmailm2.svr.pol.co.uk [195.92.193.210]) by svr1.postgresql.org (Postfix) with ESMTP id 3E79052837 for ; Mon, 23 May 2005 17:50:15 -0300 (ADT) Received: from modem-4024.llama.dialup.pol.co.uk ([217.135.191.184] helo=192.168.0.102) by cmailm2.svr.pol.co.uk with esmtp (Exim 4.41) id 1DaJsM-0002B1-IX; Mon, 23 May 2005 21:50:14 +0100 Subject: Re: Tuning planner cost estimates From: Simon Riggs To: josh@agliodbs.com Cc: "Jim C. Nasby" , pgsql-performance@postgresql.org In-Reply-To: <200505201523.16437.josh@agliodbs.com> References: <20050518002236.GU30902@decibel.org> <200505190931.47662.josh@agliodbs.com> <20050520202017.GK44623@decibel.org> <200505201523.16437.josh@agliodbs.com> Content-Type: text/plain Organization: 2nd Quadrant Date: Mon, 23 May 2005 21:46:21 +0100 Message-Id: <1116881181.3844.430.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200505/347 X-Sequence-Number: 12511 On Fri, 2005-05-20 at 15:23 -0700, Josh Berkus wrote: > > Well, that raises an interesting issue, because AFAIK none of the cost > > estimate functions currently do that. Heck, AFAIK even the piggyback > > seqscan code doesn't take other seqscans into account. > > Sure. But you're striving for greater accuracy, no? > > Actually, all that's really needed in the way of concurrent activity is a > calculated factor that lets us know how likely a particular object is to be > cached, either in the fs cache or the pg cache (with different factors for > each presumably) based on history. Right now, that's based on > estimated_cache_size, which is rather innacurate: a table which is queried > once a month has the exact same cost factors as one which is queried every > 2.1 seconds. This would mean an extra column in pg_stats I suppose. Hmmm...not sure that would be a good thing. effective_cache_size isn't supposed to be set according to how much of a table is in cache when the query starts. The setting is supposed to reflect how much cache is *available* for the current index scan, when performing an index scan on a table that is not in clustered sequence. The more out of sequence the table is, the more memory is required to avoid doing any repeated I/Os during the scan. Of course, if there are many users, the available cache may be much reduced. Best regards, Simon Riggs