Which index type is generally better for high-cardinality columns with range queries; The alternative:

Prepare for the 241 Computer Science Certification Exam with comprehensive flashcards and multiple choice questions. Enhance knowledge with explanations and hints to excel in your test journey!

Multiple Choice

Which index type is generally better for high-cardinality columns with range queries; The alternative:

Explanation:
Choosing the right index type hinges on how many distinct values a column has and what kind of queries you run. For columns with many distinct values, and when you need to handle range queries, a B-tree index is usually the best option because keys are stored in sorted order. This makes range scans efficient: you can quickly locate the start of the range and then traverse consecutive keys with good locality, providing fast lookup, comparisons, and ordered results. Bitmap indexes, by contrast, compress and organize data efficiently when there are few distinct values. They excel at combining multiple predicates with AND/OR logic on low-cardinality data, but they don’t perform well for high-cardinality columns or for maintaining performance under frequent updates. Hash indexes offer fast exact-match lookups but do not preserve ordering, so they’re not suitable for range queries. Full-text indexes are designed for searching textual content, not numeric ranges. So the best approach is to use a B-tree index for high-cardinality columns with range queries, and a bitmap index for low-cardinality columns.

Choosing the right index type hinges on how many distinct values a column has and what kind of queries you run. For columns with many distinct values, and when you need to handle range queries, a B-tree index is usually the best option because keys are stored in sorted order. This makes range scans efficient: you can quickly locate the start of the range and then traverse consecutive keys with good locality, providing fast lookup, comparisons, and ordered results.

Bitmap indexes, by contrast, compress and organize data efficiently when there are few distinct values. They excel at combining multiple predicates with AND/OR logic on low-cardinality data, but they don’t perform well for high-cardinality columns or for maintaining performance under frequent updates. Hash indexes offer fast exact-match lookups but do not preserve ordering, so they’re not suitable for range queries. Full-text indexes are designed for searching textual content, not numeric ranges.

So the best approach is to use a B-tree index for high-cardinality columns with range queries, and a bitmap index for low-cardinality columns.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy