Tutorial: Building with CleaveDB
INDEX — Speed Up Lookups
By default, primary lookups by document ID (like FIND users "jane") resolve in $O(1)$ constant time. For arbitrary property filters (like WHERE age > 30 or WHERE dept = "Eng"), CleaveDB maintains secondary B+Tree indexes created via INDEX.
Creating a single-field index
Index a single field to accelerate equality and range queries:
INDEX age ON empYou can also use the parenthesized bucket-first syntax if you prefer:
INDEX emp ON (age)Both forms construct a persistent B+Tree over the specified attribute in the background.
Composite multi-field indexes
When queries filter or sort across multiple attributes simultaneously, declare a composite index across comma-separated keys:
INDEX dept, age ON empOr equivalently:
INDEX staff ON (dept, role)Composite indexes accelerate queries that match the leading prefix of the indexed tuple (e.g. filtering by dept, or filtering by both dept and age).
Verifying active indexes
List all active indexes across your buckets using SHOW INDEXES:
SHOW INDEXESReturns a JSON payload with the total count and index specifications: {"count": 2, "data": [...]}.
