Database / LanceDB Interview questions
What is a scalar index in LanceDB?
A scalar index is an index built on a regular, non-vector column — like a string, number, or boolean field — to speed up filtering queries (a WHERE clause) against that column, distinct from the vector (ANN) indices used for similarity search.
table.create_scalar_index("category") results = table.search(query_vector).where("category = 'electronics'").limit(10).to_list()
Without a scalar index, filtering on a column requires scanning every row to check whether it matches the filter condition; with one, LanceDB can quickly narrow down to just the matching rows, similar in spirit to how a B-tree or bitmap index works in a traditional relational database.
Scalar indexes matter most for queries that combine vector search with metadata filtering — a common RAG pattern like "find documents semantically similar to this query, but only from this specific category or date range" — where an unindexed filter column would force a full scan of the filtered candidates even though the vector search itself is already using an efficient ANN index.
More Related questions...