How can I clear the cache of postgresql in a docker container?

11/24/2017

I'm using kubernethese and postgresql docker container and I'm trying to analyse the performance of some queries such as:

explain (analyze, buffers) select * from table1  as t1, table2 as t2 where t1.id = t2.id and t1.status=true and t2.status=true

I found that the query refers to memory cache after each execution.How can I clear the cache of postgresql in a docker container?

-- Slim
dockerfile
kubernetes
postgresql

1 Answer

11/24/2017

If you are just trying to measure the performance but it is not a production database, you could just stop the pod and restart it. Make sure that the database has persistence using volumes and then simply execute kubectl delete pod <name of the pod>. If you are using Deployments or DaemonSets, the pod should start again with the cache clean.

-- Javier Salmeron
Source: StackOverflow