Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id B72C41337B82 for ; Mon, 4 Oct 2010 20:06:03 -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 93548-09 for ; Mon, 4 Oct 2010 23:05:56 +0000 (UTC) X-Greylist: delayed 00:18:33.131448 by SQLgrey-1.7.6 Received: from wizmail.org (wizmail.org [217.146.107.12]) by mail.postgresql.org (Postfix) with ESMTP id 82FCB1337BBD for ; Mon, 4 Oct 2010 20:05:55 -0300 (ADT) Received: from ebony.jgh.adsl.wizards.co.uk ([217.146.123.59]) (from_AS 16353) by wizmail.org with esmtpsa (TLSv1:DHE-RSA-CAMELLIA256-SHA:256) (Exim 4.69) id 1P2tod-0001Gt-0i (return-path ); Mon, 04 Oct 2010 22:47:27 +0000 Message-ID: <4CAA5974.2050805@wizmail.org> Date: Mon, 04 Oct 2010 23:47:16 +0100 From: Jeremy Harris User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090320 Fedora/2.0.0.21-1.fc9 Thunderbird/2.0.0.21 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: How does PG know if data is in memory? References: <4CA9488C.2080502@2ndquadrant.com> In-Reply-To: <4CA9488C.2080502@2ndquadrant.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 201010/30 X-Sequence-Number: 40449 On 10/04/2010 04:22 AM, Greg Smith wrote: > I had a brain-storming session on this subject with a few of the hackers in the community in this area a while back I haven't had a chance to do something with yet (it exists only as a pile of scribbled notes so far). There's a couple of ways to collect data on what's in the database and OS cache, and a couple of ways to then expose that data to the optimizer. But that needs to be done very carefully, almost certainly as only a manual process at first, because something that's producing cache feedback all of the time will cause plans to change all the time, too. Where I suspect this is going is that we may end up tracking various statistics over time, then periodically providing a way to export a mass of "typical % cached" data back to the optimizer for use in plan cost estimation purposes. But the idea of monitoring continuously and always planning based on the most recent data available has some stability issues, both from a "too many unpredictable plan changes" and a "ba d > short-term feedback loop" perspective, as mentioned by Tom and Kevin already. Why not monitor the distribution of response times, rather than "cached" vs. not? That a) avoids the issue of discovering what was a cache hit b) deals neatly with multilevel caching c) feeds directly into cost estimation. Cheers, Jeremy