Skip to main content

BTree Index

BTree index builds a logical B-tree structure over SST files, enabling efficient point lookups and range queries on scalar columns. Use it for selective predicates on scalar columns such as identifiers, timestamps, categories with many distinct values, or other columns frequently used in WHERE clauses.

Supported predicate shapes include:

PredicateExample
Equalityname = 'a200'
INname IN ('a200', 'a300')
Rangeprice >= 10 AND price < 100
Null checksname IS NOT NULL
AND / OR combinationsname = 'a200' OR name = 'a300'

LIKE, startsWith, contains, and NOT IN predicates may still need broader index file reads. Use btree-index.fallback-scan-max-size to cap fallback range and string scans by the total candidate index file size. For keyword-style text retrieval, use Full-Text Index instead.

For table prerequisites, see Global Index. For refresh, coverage modes, and shared build options, see Manage Global Indexes.

Build BTree Index​

Use the populated shared example table. It includes the indexed column and the dt partition key used in the examples below.

-- Create BTree index on 'name' column
CALL sys.create_global_index(
table => 'db.my_table',
index_column => 'name',
index_type => 'btree'
);

You can build only selected partitions:

CALL sys.create_global_index(
table => 'db.my_table',
index_column => 'name',
index_type => 'btree',
partitions => 'dt=2026-06-18;dt=2026-06-19'
);

Query with BTree Index​

Once a BTree index is built, it is automatically used during scan when a filter predicate matches the indexed column.

SELECT * FROM my_table WHERE name IN ('a200', 'a300');

BTree Options​

OptionDefaultDescription
sorted-index.records-per-file25000000Expected number of records per sorted global index file for BTree, Bitmap, and Multivalue builds.
sorted-index.build.max-parallelism4096Maximum Flink or Spark parallelism for building sorted global indexes.
btree-index.block-size64 kbBlock size used by BTree index files.
btree-index.bloom-filter.enabledfalseWhether to write a Bloom filter to accelerate BTree equality and IN lookups.
btree-index.cache-size128 mbCache size used by BTree index readers.
btree-index.high-priority-pool-ratio0.1Fraction of btree-index.cache-size reserved for high-priority data such as index blocks; the rest caches data blocks. Must be in [0, 1).
btree-index.fallback-scan-max-size256 mbMaximum total size of candidate BTree global index files to allow fallback index scans. Set to 0 b to disable fallback scans.
btree-index.compressionnoneCompression algorithm used by BTree index blocks.
btree-index.compression-level1Compression level used by codecs that support levels, such as zstd.

The legacy btree-index.records-per-range and btree-index.build.max-parallelism keys are still recognized as fallback keys.

Drop BTree Index​

CALL sys.drop_global_index(
table => 'db.my_table',
index_column => 'name',
index_type => 'btree'
);