Bitmap scan cost(11559.98) < index scan cost(32243.95) < seq scan cost(35811)位图扫描源码解析 位图扫描分为Bitmap Index Scan和Bitmap Heap Scan 两个阶段。Bitmap Index Scan:扫描btree index的数据,构建并返回TID Bitmap;Bitmap Heap Scan:依赖下层算子返回的TID Bitmap,扫描heap data,返回符...
Bitmap Heap Scan on t_lei (cost=3.90..14.75 rows=1 width=68) (actual time=0.089..0.089 rows=0 loops=1) ———>>>此处 Recheck Cond: (oid < '100'::oid)———>>>此处 Filter: (relname = 'dump'::name) -> Bitmap Index Scan on idx_t_lei_1 (cost=0.00..3.90 rows=190 width=...
而BitMap Index Scan一次性将满足条件的索引项全部取出,并在内存中进行排序, 然后根据排序后的索引项访问表数据,也就是执行计划中的Bitmap Heap Scan。 bitmap index scan 内部优化机制:https://www.postgresql.org/message-id/12553.1135634231@sss.pgh.pa.us 第三个问题:Recheck Cond的目的是什么 BitMap Heap ...
Bitmap Heap Scan on t1 (cost=3.31..4.62 rows=1 width=12) Recheck Cond: ((c3 = 30) AND (c2 = 20)) Filter: (c1 = 10) -> BitmapAnd (cost=3.31..3.31 rows=1 width=0) -> Bitmap Index Scan on idx_t13 (cost=0.00..1.53 rows=10 width=0) Index Cond: (c3 = 30) -> Bitma...
可以看到在对idx_c5上执行了一个Bitmap Index Scan,由于Bitmap Index Scan记录的是符合条件的记录所在的block,而非记录的指针,通过类似于Oracle位图索引的检索模式进行数据的筛选,然后对这些位图信息指向的block排序后再进行回表(查询),Bitmap Index Scan之后有一个Recheck Cond是因为解析block的时候需要Recheck 。
QUERY PLAN --- Bitmap Heap Scan onpublic.t_dwxx t1 (cost=32.33..88.38rows=33width=20) Output: dwmc, dwbh, dwdz Recheck Cond: (((t1.dwbh)::text >10000::text)AND((t1.dwbh)::text <15000::text)AND((t1.dwdz)::text >=DWDZ10000::text)AND((t1.dwdz)::text <=DWDZ15000::text)...
-- Bitmap Heap Scan on public.t_dwxx t1 (cost=32.33..88.38 rows=33 width=20) Output: dwmc, dwbh, dwdz Recheck Cond: (((t1.dwbh)::text > '10000'::text) AND ((t1.dwbh)::text < '15000'::text) AND ((t1.dwdz)::text ...
值得注意的是在BitmapIndexScan后有一步:Recheck,这是因为位图索引扫描只是把Heap Block ID找出来,并没有把符合条件的元组找出来,因此出现了Recheck这一步. 五、参考资料 PostgreSQL indexing: Index scan vs. Bitmap scan vs. Sequential scan Bitmap indexes ...
,loc); Bitmap Heap Scan on xxx (cost=8.84..13.37 rows=1 width=1194) (actual time=0.940..2.547 rows=215 loops=1) Output: xxx Recheck Cond: (('0103000020E610000001000000050000004607CD68194F5E40A30954F216CA42404607CD68194F5E4017898ACF2AC742401DBB4CC022505E4017898ACF2AC742401DBB4CC022505E40...
QUERY PLAN---Bitmap Heap Scan on sample (cost=4.29..14.24rows=5width=256) Recheck Cond: (letter='d'::text)-> Bitmap Index Scan on i_sample (cost=0.00..4.29rows=5width=0) Index Cond: (letter='d'::text) (4rows) postgres=# postgres=# EXPLAIN SELECT *FROM sample WHERE letter...