我對PostgreSQL 中 Bitmap Heap scan 與 Bitmap Index scan 的學習


開始

我個人的理解,當 where 條件出現 or 或者 and 之類,有可能產生這種狀況:

postgres=#  explain analyze select id,deptno from gaotab where id=100 or id=300;
                                                         QUERY PLAN                                                         
----------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on gaotab  (cost=8.52..13.34 rows=2 width=8) (actual time=31.201..31.227 rows=2 loops=1)
   Recheck Cond: ((id = 100) OR (id = 300))
   ->  BitmapOr  (cost=8.52..8.52 rows=2 width=0) (actual time=13.738..13.738 rows=0 loops=1)
         ->  Bitmap Index Scan on idx_id_dept  (cost=0.00..4.26 rows=1 width=0) (actual time=13.729..13.729 rows=1 loops=1)
               Index Cond: (id = 100)
         ->  Bitmap Index Scan on idx_id_dept  (cost=0.00..4.26 rows=1 width=0) (actual time=0.008..0.008 rows=1 loops=1)
               Index Cond: (id = 300)
 Total runtime: 42.876 ms
(8 rows)

postgres=# 

就是說,bitmap index scan 就相當於  index scan。只是它們需要組合起結果來,所以被稱為  Bitmap Index Scan。

Bitmap Index Scan 的結果組合起來,就是 Bitmap Heap Scan(可能涉及排序等)。

[作者:技術者高健@博客園  mail: luckyjackgao@gmail.com ]

結束


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM