Clear cache in Windows I would like to make some timing tests in my PostgreSQL database. I would like to clear cache every time I run a query to disable influence of caching on my timing results. I've read some topics about clearing that cache in Linux, but not found how to do that in Windows. Could you help me please? 

OS: Windows 10.
PostgreSQL: 9.6.0.
There's no way to clear the caches easily. On Linux you can stop the database server and use the drop_caches facility to clear the OS cache; be sure to heed the warning there to run sync first.

There is also a presentation from 2ndquadrant that shows Inside the PostgreSQL Shared Buffer Cache. It outlines the following points:


Windows does not perform well with large shared buffers
settings. Effective maximum size is around 10,000-50,000
buffers
I This talk is more appropriate for UNIX-like platforms; can’t
really take full advantage of the buffer cache on Windows


Digging deeper into this, I found an open source project that clears the cache. I don't see many people forking or using this project though. The safest way is to just restart the server since there is no way to bypass or flush the database's cache. But feel free to look at the code and see if it will work for you.

You can see all prepared statements available in the session by querying the pg_prepared_statements system view. This will allow you to see if the plan cache was cleared. You might even be able to get away with a DEALLOCATE statement. This might be what you are looking for...