“位图堆扫描”中的“堆块”是什么意思?

Jes*_*pez 10 postgresql explain postgresql-9.4

我有这个查询:

EXPLAIN (ANALYZE, BUFFERS) 
SELECT * FROM test
WHERE
    timestamp_range @> '2015-01-22 23:00:00'::timestamp
    AND data_int_array @> '{49, 61}'::integer[];
Run Code Online (Sandbox Code Playgroud)

哪些输出:

Bitmap Heap Scan on test  (cost=16.74..20.75 rows=1 width=113) (actual time=0.364..0.367 rows=2 loops=1)
  Recheck Cond: ((timestamp_range @> '2015-01-22 23:00:00'::timestamp without time zone) AND (data_int_array @> '{49,61}'::integer[]))
  Heap Blocks: exact=1
  Buffers: shared hit=8
  ->  BitmapAnd  (cost=16.74..16.74 rows=1 width=0) (actual time=0.351..0.351 rows=0 loops=1)
        Buffers: shared hit=7
        ->  Bitmap Index Scan on ix_test_interval  (cost=0.00..4.40 rows=17 width=0) (actual time=0.130..0.130 rows=12 loops=1)
              Index Cond: (timestamp_range @> '2015-01-22 23:00:00'::timestamp without time zone)
              Buffers: shared hit=2
        ->  Bitmap Index Scan on ix_test_data_int_array_data_json  (cost=0.00..12.08 rows=11 width=0) (actual time=0.211..0.211 rows=6 loops=1)
              Index Cond: (data_int_array @> '{49,61}'::integer[])
              Buffers: shared hit=5
Planning time: 0.396 ms
Execution time: 0.484 ms
Run Code Online (Sandbox Code Playgroud)

我已阅读文档“ Using Explain ”,但没有找到对堆块的任何参考。

拜托,你能告诉我Heap BockBuffers在 a 中的含义和关系Bitmap Heap Scan吗?

我在跑:“ PostgreSQL 9.4.5, compiled by Visual C++ build 1800, 64-bit

jja*_*nes 10

位图可以存储行的位图,或者如果它变得太大而无法放入 work_mem 中,它可以通过存储块的位图来“有损”。它可以有选择地执行此操作,因此某些块可以进行有损转换,而另一些则不能。

如果它有损,那么堆扫描必须重新检查它访问的每个有损块中的每一行,因为它不再有关于该块中哪些特定行满足搜索条件的信息。

“Heap Blocks:exact=1”表示它只访问了一个块,并且没有损失。(所以你返回的两行都在同一个块中)

这与缓冲区数据一致。的Bitmap Index ScansBitmapAnd在总打7块。堆扫描又命中了 1 个,使其达到 8 个。