How to create bitmap index in PostgreSQL? (Does it even have bitmap index ?)

14k views Asked by At

I have been "googling" at least for an hour, but I was unable to find how to create a bitmap index in PostgreSQL, so my question is very simple: how to write this command (from Oracle) in PostgreSQL:

CREATE BITMAP INDEX name  ON table (column);
2

There are 2 answers

0
Correcter On

The bitmap of pages is created dynamically for each query. It is not cached or re-used, and is discarded at the end of the bitmap index scan.

It doesn't make sense to create the page bitmap in advance because its contents depend on the query predicates.

Bitmap index create a separate bitmap (a sequence of 0 and 1) for each possible value of the column, where each bit corresponds to a string with an indexed value. Bitmap indexes are optimal for data where bit unique values (example, gender field)

PostgreSQL does not provide persistent bitmap index. But it can be used in database to combine multiple indexes. PostgreSQL scans each needed index and prepares a bitmap in memory giving the locations of table rows that are reported as matching that index’s conditions. The bitmaps are then ANDed and ORed together as needed by the query. Finally, the actual table rows are visited and returned.

0
dilanSachi On

If you need, you can integrate roaring bitmaps into PostgreSQL. Roaring bitmaps are compressed bitmaps that tend to outperform conventional compressed bitmaps such as WAH, EWAH, or Concise.

You can use this repo to integrate roaring bitmaps. It contains an improved fork of Roaring bitmap implementation in greenplum-db.