What best describes the structure of a bitmap index in a database?
Think about how bits can represent presence or absence efficiently.
A bitmap index creates a bitmap for each distinct value in a column. Each bit in the bitmap corresponds to a row in the table. If the bit is 1, the row contains that value; if 0, it does not. This allows very fast logical operations for queries.
In which scenario is a bitmap index most effective?
Consider how many distinct values the column has and how that affects bitmap size.
Bitmap indexes work best on columns with low cardinality (few distinct values) because the bitmaps remain small and efficient. High cardinality columns would create large bitmaps, reducing efficiency.
Consider a query filtering rows where two low-cardinality columns meet certain conditions combined with AND. How does a bitmap index improve performance?
Think about how bitmaps can be combined logically.
Bitmap indexes allow fast bitwise operations like AND, OR, and NOT on bitmaps representing different conditions. This lets the database quickly find rows matching multiple conditions without scanning all rows.
Which statement correctly compares bitmap indexes and B-tree indexes?
Consider how each index type handles range queries and distinct values.
B-tree indexes are efficient for range queries and high-cardinality columns. Bitmap indexes excel at equality queries on low-cardinality columns but are less efficient for range scans because bitmaps represent discrete values.
Why are bitmap indexes generally not recommended for tables with frequent insert, update, or delete operations?
Think about how bitmaps are stored and updated when data changes.
Bitmap indexes use bit arrays that need to be updated when rows change. This often requires locking parts of the index, which can cause contention and slow down write operations. Hence, they are best for mostly read-only or infrequently updated tables.