Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 509DF13364DE; Tue, 3 May 2011 10:53:47 -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 37368-06; Tue, 3 May 2011 13:53:28 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from elizabeth.gransy.com (elizabeth.gransy.com [89.187.132.199]) by mail.postgresql.org (Postfix) with ESMTP id 358171337A5D; Tue, 3 May 2011 10:53:27 -0300 (ADT) Received: from sq.gransy.com (localhost [127.0.0.1]) by elizabeth.gransy.com (Postfix) with ESMTP id 539F415E439F; Tue, 3 May 2011 15:53:27 +0200 (CEST) Received: from 85.161.121.16 (SquirrelMail authenticated user tv@fuzzy.cz) by sq.gransy.com with HTTP; Tue, 3 May 2011 15:53:27 +0200 Message-ID: <6a9c2326b29433bde0de5c8a887d65be.squirrel@sq.gransy.com> In-Reply-To: References: Date: Tue, 3 May 2011 15:53:27 +0200 Subject: Re: [GENERAL] Can we Flush the Postgres Shared Memory ? From: tv@fuzzy.cz To: "raghu ram" Cc: "Raghavendra" , "Simon Riggs" , "pgsql-admin" , "pgsql-general" , "pgsql novice" User-Agent: SquirrelMail/1.4.21 MIME-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal 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: 201105/23 X-Sequence-Number: 37460 > On Tue, May 3, 2011 at 6:01 PM, Raghavendra < > raghavendra.rao@enterprisedb.com> wrote: > >> >> On Tue, May 3, 2011 at 5:37 PM, Simon Riggs >> wrote: >> >>> On Tue, May 3, 2011 at 11:54 AM, raghu ram >>> wrote: >>> >>> > It may be a silly question, still out of curiosity I want to know, is >>> there >>> > any possible way to flush the Postgres Shared Memory without >>> restarting >>> the >>> > cluster. >>> > In Oracle, we can flush the SGA, can we get the same feature here.. >>> > Thanks in Advance. >>> >>> >>> The CHECKPOINT command will do this for you. >>> >> >> >> > According to PostgreSQL documentation, whenever you execute "CHECKPOINT" > in > the database,it will flush the modified data files presented in the Shared > Buffers retuned to the Disk. > > http://www.postgresql.org/docs/9.0/static/sql-checkpoint.html > > Is this clears the entire shared memory cache and same time,if i execute > fresh SQL statement, Data will be retuned from disk?? No. Checkpoint means all dirty buffers are written to the datafiles, it does not mean emptying the shared buffers. Checkpoints happen regularly so this would have an unwanted impact on performance. And besides that, there's a page cache maintained by the OS (not sure if you're running Linux or Windows). So even when the block does not exist in the shared buffers, it may be in the page cache (thus not read from the drive). Dropping the page cache is quite simple (http://linux-mm.org/Drop_Caches), emptying the shared buffers is not that simple - I guess the easiest way is to restart the db. What are you trying to achieve? Why do you need this? Tomas