Cloud Parts

Bitmap indexes

One bitmap per distinct value, with a bit per row, so filters on several low-cardinality columns combine with fast AND and OR.

How they work

In an Oracle bitmap index each key value has a bitmap with one bit per possible row; a set bit means that row holds the value, and a mapping function turns bit positions into row IDs. Oracle aims them at data warehouses where queries combine many columns ad hoc, on columns with few distinct values compared with the number of rows, in tables that are read-only or rarely changed. Updating one row locks the whole key entry, and with it every row sharing the value, which is why Oracle calls them unsuitable for many OLTP applications.

PostgreSQL has no bitmap index type, but its plans often show a related step. A bitmap index scan collects the locations of matching rows from any index (B-tree, GIN, BRIN) into an in-memory bitmap, can AND and OR bitmaps from several indexes, then reads the table pages in physical order. It is a way of running one query rather than a stored index, and it loses the index’s order, so an ORDER BY needs a separate sort.

Sources

Improve this page on GitHub