Re: clearing the buffer cache - Mailing list pgsql-general

From Greg Smith
Subject Re: clearing the buffer cache
Date
Msg-id Pine.GSO.4.64.0902142136520.13196@westnet.com
Whole thread Raw
In response to clearing the buffer cache  (Sam Mason <sam@samason.me.uk>)
List pgsql-general
On Fri, 13 Feb 2009, Sam Mason wrote:

> I was hoping for a function I could call, or maybe some variable I write
> to, that would cause the contents to be invalidated.

For most people, just restarting the server is acceptable overhead, which
is why nobody has bothered to write such a thing.  It wouldn't be too
difficult for someone familiar with the basic internals involved to hack
in such a function, getting it accepted into the standard distribution
would be quite another problem though.

As you noticed, just "select * from t" where t is a dummy table doesn't
help here anymore.  What you could do is write a quick PL/pgSQL function
that simulates that in a way that isn't optimized away.  Create a table
that's bigger than shared_buffers with a primary key, then iterate over
that table record at a time using that key until you've scanned records to
wipe out the cache.  You can use contrib/pg_buffercache to confirm the
function is doing what you expect.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

pgsql-general by date:

Previous
From: Rodrigo Gonzalez
Date:
Subject: Re: pg_hba reload
Next
From: John R Pierce
Date:
Subject: Re: pg_hba reload