Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A532837BA4E; Mon, 29 Sep 2008 03:55:58 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 55479-08; Mon, 29 Sep 2008 03:55:55 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from westnet.com (westnet.com [216.187.52.2]) by postgresql.org (Postfix) with ESMTP id 0943237BA30; Mon, 29 Sep 2008 03:55:54 -0300 (ADT) Received: from westnet.com (localhost [127.0.0.1]) by westnet.com (8.14.0/8.14.0) with ESMTP id m8T6tqfo020831; Mon, 29 Sep 2008 02:55:52 -0400 (EDT) Received: from localhost (gsmith@localhost) by westnet.com (8.14.0/8.13.2/Submit) with ESMTP id m8T6tqLM020828; Mon, 29 Sep 2008 02:55:52 -0400 (EDT) X-Authentication-Warning: westnet.com: gsmith owned process doing -bs Date: Mon, 29 Sep 2008 02:55:52 -0400 (EDT) From: Greg Smith X-X-Sender: gsmith@westnet.com To: Matthew Pulis cc: pgsql-admin@postgresql.org, pgsql-general@postgresql.org Subject: Re: [GENERAL] PostgreSQL Cache In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/324 X-Sequence-Number: 30417 On Mon, 29 Sep 2008, Matthew Pulis wrote: > I need to perform some timed testing, thus need to make sure that disk cache > does not affect me. Is clearing the OS (Ubuntu) disk cache, ( by running: > sudo echo 3 | sudo tee /proc/sys/vm/drop_caches ) enough to do this? What you should do is: 1) Shutdown the database server (pg_ctl, sudo service postgresql stop, etc.) 2) sync 3) sudo echo 3 > /proc/sys/vm/drop_caches 4) Start the database server That will clear both the database and OS cache with a minimum of junk left behind in the process; clearing the cache without a sync is a bad idea. Note that all of this will still leave behind whatever cache is in your disk controller card or on the disk themselves available. There are some other techniques you could consider. Add a setp 2.5 that generates a bunch of data unused by the test, then sync again, and you've turned most of that into useless caching. Ideally, your test should be running against a large enough data set that the dozens or couple of hundred megabytes that might be in those will only add a bit of noise to whatever you're testing. If you're not running a larger test or going through tasts to make the caches clear, the only easy way to make things more clear is to reboot the whole server. -- * Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD