Re: clearing the buffer cache

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: clearing the buffer cache
Date: 2009-02-16 17:00:16
Message-ID: 20090216170016.GY32672@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Feb 16, 2009 at 11:09:59AM -0500, Chris Mayfield wrote:
> >With recent versions of Linux you can flush the system's buffer cache by
> >doing:
> >
> > # echo 3 > /proc/sys/vm/drop_caches
>
> You can also try something like this:
> http://wiki.services.openoffice.org/wiki/Cold-start-simulator
>
> Shutting down the server and running fillmem has worked for me, but that
> might take too long in your situation of thousands of small queries.

Why is this better than asking the kernel to drop its caches? The
kernel could reasonably assume that because you only touched the data in
a page once it could swap the "fillmem"s data out in preference to the
page cache.

Even if it did, you need to restart the server which is what prevents
testing going quickly in the first place.

> But I guess "SELECT * FROM large_table" would have taken just as long
> anyway.

This doesn't work on several levels any more; PG is smart enough to
recognize that this is what's happening and only uses a small buffer for
this (256KB at the moment). Linux can be smart enough as well which is
why you need to ask it to drop the page cache.

--
Sam http://samason.me.uk/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message joel garry 2009-02-16 17:51:42 Re: Which SQL is the best for servers?
Previous Message Paulie 2009-02-16 16:57:14 Re: Which SQL is the best for servers?