Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 865FD1337B74 for ; Sat, 2 Oct 2010 23:43:13 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 19046-08 for ; Sun, 3 Oct 2010 02:43:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id E1BFF1337B5A for ; Sat, 2 Oct 2010 23:43:05 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 22CB6AE5E9; Sun, 3 Oct 2010 10:43:01 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id XjsM78HH6SgY; Sun, 3 Oct 2010 10:42:55 +0800 (WST) Received: from [10.1.1.4] (124-148-209-200.dyn.iinet.net.au [124.148.209.200]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 4C369AE5DF; Sun, 3 Oct 2010 10:42:55 +0800 (WST) Message-ID: <4CA7EDA5.4080401@postnewspapers.com.au> Date: Sun, 03 Oct 2010 10:42:45 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.12) Gecko/20100914 Thunderbird/3.0.8 MIME-Version: 1.0 To: Richard Troy CC: pgsql-performance@postgresql.org Subject: Re: How does PG know if data is in memory? References: In-Reply-To: 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.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201010/17 X-Sequence-Number: 40436 On 3/10/2010 7:39 AM, Richard Troy wrote: > I can't speak for modern "OpenVMS", but "back in the day", VMS had a very > effective memory management strategy which, in effect, made it as if all > memory was a cache for disk. It did this by means of a mechanism by which > to identify all potentially reachable disk space. When disk was read in, > an entry would be made mapping the memory to the disk space from which it > came - and if it was later updated, the mapping entry was marked "dirty." > Whenever disk access was contemplated, a check was made to see if it was > already in memory and if so, it'd provide access to the in-memory copy > instead of doing the read again. (This also permitted, under some > circumstances, to reduce write activity as well.) That's how Linux's memory management works, too, at least if I understand you correctly. Pretty much every modern OS does it. Pg is reliant on the operating system's disk cache, and has some minimal knowledge of it (see effective_cache_size) . I don't know how shared_buffers management works, but certainly at the OS cache level that's what already happens. -- Craig Ringer Tech-related writing at http://soapyfrogs.blogspot.com/