为什么当我清除postgresql缓存时,我仍然在查询计划中遇到缓冲区?

时间:2017-11-27 08:23:34

标签: postgresql

我正在使用docker postgres图像,为了进行性能测量,我想清除缓存。首先,我运行此命令:

docker run -it --rm postgres:9.6.4-alpine -c "sync && echo 3> /proc/sys/vm/drop_caches"

然后:

kubectl delete pod db 

之后我重启pod.I执行此查询:

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:*');

我有这个查询计划:

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

我不明白为什么查询使用内存缓存。该命令不会清除缓存totalllt。如果不是这样,我如何刷新内存缓存或者不可能这样做?

0 个答案:

没有答案