Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 9388E65B147 for ; Tue, 16 Mar 2010 17:54:36 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 04876-06 for ; Tue, 16 Mar 2010 20:54:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.10]) by mail.postgresql.org (Postfix) with ESMTP id DFF62640188 for ; Tue, 16 Mar 2010 17:54:25 -0300 (ADT) Received: from [192.168.0.105] (pool-96-244-14-10.bltmmd.fios.verizon.net [96.244.14.10]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0MCMOD-1O083D2JWb-0097jA; Tue, 16 Mar 2010 21:51:52 +0100 Message-ID: <4B9FEF65.50005@2ndquadrant.com> Date: Tue, 16 Mar 2010 16:51:49 -0400 From: Greg Smith User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Pierre C CC: Nikolas Everett , Dave Crooke , Paul McGarry , pgsql-performance@postgresql.org Subject: Re: shared_buffers advice References: <4B9F3302.4020900@2ndquadrant.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX18e6C9lslX9YwlpY53j+U5Vgl4bAekYOVAxRu9 zdhyE03XzewiNx4++TbZgHW6JL9T2Ig6Yf+i16+QPCPr//WxQ4 5XnuvjOv7FCkluNcAjYaZtLkZ7lc6eE X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/175 X-Sequence-Number: 38000 Pierre C wrote: > Actually, I meant that in the case of a seq scan, PG will try to use > just a few buffers (a ring) in shared_buffers instead of thrashing the > whole buffers. But if there was actually a lot of free space in > shared_buffers, do the pages stay, or do they not ? Pages inserted into the ring buffer and later re-used for new data do not stay behind even if there is room for them. There's a potential improvement possible in that code involving better management of the situation where the buffer cache hasn't actually reached full capacity yet, but as it's an unusual case it's hard to justify optimizing for. Besides, the hope is that in this case the OS cache will end up caching everything anyway until it has a reason to evict it. So if you follow the rest of the data suggesting you should not give all the memory to PostgreSQL to manage, you end up with a reasonable solution to this problem anyway. Those pages will just live in the OS cache instead of the database's, with only a few trickling in and staying behind each time you do a sequential scan. -- Greg Smith 2ndQuadrant US Baltimore, MD PostgreSQL Training, Services and Support greg@2ndQuadrant.com www.2ndQuadrant.us