PostgreSQL bitmap Index

Source: Internet
Author: User

What is bitmap index?
Bitmap indexes use a single-digit chart to store the visible structure of records.
What are the features of Bitmap indexes?
Bitmap index implementation method: Use a BIT to indicate whether the value corresponding to this attribute exists. The existence is 1 and the absence is 0.
Bitmap index function scope: processing status value, can be said to be highly selectable.
What are the advantages and disadvantages of Bitmap indexes?
Advantages of Bitmap indexes: A, which can greatly reduce the compression ratio and B, which can quickly locate whether the retrieved value is visible or not.
Bitmap index defects: A, the bitmap itself is unordered for storage, and each retrieval is A random IO on the disk; B, because of compression storage, it is suitable for OLAP applications. Of course, you do not need to compress, such as INFOBRIGHT.


PostgreSQL does not support bitmap indexing, so it does not support the Compressed Storage of Bitmap information. However, when creating a query plan, a Bitmap Heap Table is created for common indexes (such as BTREE and HASH.
Where
Bitmap Index Scan is used to create a single-digit chart in memory. Each BIT represents a page related to filtering conditions. This page may have 1 data and cannot be 0.
Bitmap Heap Scan. In the memory, the page corresponding to the bit chart pointer is scanned sequentially to exclude non-conforming records.


Let's look at the example of Bitmap scanning.
The is_visible field of the bitmap_test table is highly selective and has only two values,
For the query statement select is_visible from bitmap_test where is_visible = 'yes', the corresponding query plan is as follows:

                                                                 QUERY PLAN                                                                 -------------------------------------------------------------------------------------------------------------------------------------------- Bitmap Heap Scan on bitmap_test  (cost=2023.16..4157.75 rows=99967 width=4) (actual time=24.373..41.054 rows=100000 loops=1)   Recheck Cond: (is_visible = 'yes'::bpchar)   ->  Bitmap Index Scan on idx_bitmap_is_visible  (cost=0.00..1998.17 rows=99967 width=0) (actual time=24.252..24.252 rows=100000 loops=1)         Index Cond: (is_visible = 'yes'::bpchar) Total runtime: 47.175 ms(5 rows)Time: 47.725 ms





According to the EXPLAIN results of the preceding query, a single-digit chart is created first, and then pushed up to the page. On the page, recheck that the values of each record meet the filtering conditions. Print the result after all ends.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.