7

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);
7
  • no, Postgres does not have it, but if you have very few possible values (and especially if they are very asymmetrically dispersed) consider trying PARTIAL INDEX Commented Aug 20, 2015 at 7:53
  • You can put for what purpose you want to create bitmat, refer this documentation which says bit map is created automatically by postgre (in memory) but not by any user. Commented Aug 20, 2015 at 8:17
  • have you tried reading the documentation? Commented Aug 20, 2015 at 8:20
  • 1
    to mef: I did, no answer found ... to Marmik: I was looking into explain plan for my query which was ideal for using of bitmap indexes but non was automatically created and sequence scan was used instead Commented Aug 20, 2015 at 8:31
  • If you have a slow query please read this: stackoverflow.com/tags/postgresql-performance/info and then post the relevant information. Commented Aug 20, 2015 at 9:04

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.