I'm using a docker postgres image, and for a perfomance measure I want to clear the cache. First of all I run this command:
docker run -it --rm postgres:9.6.4-alpine -c "sync && echo 3> /proc/sys/vm/drop_caches"
Then:
kubectl delete pod db
After that I restart the pod.I execute this query:
explain (analyze, buffers) select e.name
from table1 as e, table2 as prov
where e.provider_id = prov.id
and e.status = true and prov.status = true
and to_tsvector('simple', e.name) @@ to_tsquery('simple', 'a:*');
I got this query plan:
Hash Join (cost=187.59..1114.19 rows=2727 width=30) (actual
time=2.291..4.432 rows=3174 loops=1)
Hash Cond: (e.provider_id = prov.id)
Buffers: shared hit=77 read=121
-> Bitmap Heap Scan on table1 e (cost=46.15..934.90 rows=2819 width=34) (actual time=0.619..2.086 rows=3180 loops=1)
Recheck Cond: (to_tsvector('simple'::regconfig, (name)::text) @@ '''a'':*'::tsquery)'
Filter: status
Rows Removed by Filter: 62
Heap Blocks: exact=138
Buffers: shared hit=52 read=94
-> Bitmap Index Scan on table1_name_index (cost=0.00..45.45 rows=2860 width=0) (actual time=0.603..0.603 rows=3242 loops=1)'
Index Cond: (to_tsvector('simple'::regconfig, (name)::text) @@ '''a'':*'::tsquery)
Buffers: shared hit=1 read=7
-> Hash (cost=90.84..90.84 rows=4048 width=4) (actual time=1.639..1.639 rows=4048 loops=1)
Buckets: 4096 Batches: 1 Memory Usage: 175kB
Buffers: shared hit=22 read=27
-> Seq Scan on table2 prov (cost=0.00..90.84 rows=4048 width=4) (actual time=0.005..1.037 rows=4048 loops=1)
Filter: status
Rows Removed by Filter: 136
Buffers: shared hit=22 read=27
Planning time: 0.530 ms
Execution time: 4.600 ms
I don't understand why does the query uses the memory cache.Does the command doesn't clear the cache totalllt.if it is not the case, how can I flush the memory cache or it's not possible to do that?