Thread: How to clear linux file cache?
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
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
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
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