我对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 ]

结束

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值