开始
我个人的理解,当 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 ]
结束