How to clear linux file cache?

Started by Janning Vygenover 21 years ago4 messagesgeneral
Jump to latest
#1Janning Vygen
vygen@gmx.de

Hi,

i am testing a few queries in my postgresql DB. The first query after reboot
is always slower because of an empty OS page/file cache.

I want to test my queries without any files in the linux kernel cache, just to
know what would be the worst execution time. At the moment i stop postgresql
and do something like

find / -name foo

for a few minutes and start postgresql afterwards.

I search manuals with "apropos page cache" and found sync but it doesnt clear
the cache, just writes dirty pages back to disk. I googled for "linux clear
page cache" but did not found what i need. (of course i searched the
archives, too)

So how do i easily empty all page/file caches on linux (2.4.24)?

Sorry for beeing a little bit OT, but i think my question still relates to
postgresql.

kind regards,
janning

#2Doug McNaught
doug@mcnaught.org
In reply to: Janning Vygen (#1)
Re: How to clear linux file cache?

Janning Vygen <vygen@gmx.de> writes:

So how do i easily empty all page/file caches on linux (2.4.24)?

Probably the closest you can easily get is to put the Postgres data
files on their own partition, and unmount/remount that partition
before running yuour tests. Unmounting will sync and throw away all
cached file data for that partition.

-Doug

#3Chris Browne
cbbrowne@acm.org
In reply to: Janning Vygen (#1)
Re: How to clear linux file cache?

The world rejoiced as vygen@gmx.de (Janning Vygen) wrote:

So how do i easily empty all page/file caches on linux (2.4.24)?

You can empty them of PostgreSQL-related data by filling them with
something else.

You might head to some directory that has more data in it than you
have memory, and "cat" the files...
--
"cbbrowne","@","linuxfinances.info"
http://www.ntlug.org/~cbbrowne/sap.html
"As far as Saddam Hussein being a great military strategist, he is
neither a strategist, nor is he schooled in the operational arts, nor
is he a tactician, nor is he a general, nor is he as a soldier. Other
than that, he's a great military man, I want you to know that."
-- General Norman Schwarzkopf, 2/27/91

#4Janning Vygen
vygen@gmx.de
In reply to: Doug McNaught (#2)
Re: How to clear linux file cache?

Am Dienstag, 16. November 2004 16:39 schrieb Doug McNaught:

Janning Vygen <vygen@gmx.de> writes:

So how do i easily empty all page/file caches on linux (2.4.24)?

Probably the closest you can easily get is to put the Postgres data
files on their own partition, and unmount/remount that partition
before running yuour tests. Unmounting will sync and throw away all
cached file data for that partition.

very good idea. i will do it like this.

thanks.
janning