> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lancedb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Distributed Search

> How LanceDB Enterprise distributes index execution, data reads, and caching across query nodes and executors.

Enterprise only

LanceDB Enterprise separates query planning from index execution and data reads
so that search can use the memory, CPU, and caches of multiple machines. A query
node plans and coordinates a query. Executors search indexes, read table
data, and return partial results for the query node to combine.

For the service components and overall request paths, see
[Architecture](https://docs.lancedb.com/oss/v0-42-0/index.md#architecture).

## Search architecture

LanceDB Enterprise prioritizes horizontal scalability. Index execution on a
single node can be limited by the memory available to cache the index for fast
search and by the CPU available to execute queries. Dividing one logical index
into multiple **index segments** lets each segment be distributed to an
executor, cached independently, and searched in parallel with other segments.

The two serving components have different responsibilities:

| Component | Responsibility |
| - | - |
| Query node (query planning + routing fleet) | Accept requests, plan queries, distribute work, and combine results. |
| Executor (executor + cache fleet) | Cache index structures and table data, execute subplans from the query node, and return partial results. |

Eligible scalar index operations can also execute on executors. See [scalar
indexes](https://docs.lancedb.com/oss/v0-42-0/indexing/scalar-index.md) and
[filtering](https://docs.lancedb.com/oss/v0-42-0/search/filtering.md) for index types and query
syntax.

For example, consider a vector index with six segments served by three
executors. Each executor searches its two segments and returns its best 10
candidates. The query node compares the candidates returned by all three
executors and selects the final 10. This example assumes enough matching rows
and the default search path without additional reranking.

When a vector index has a single large segment or a few skewed segments that
would otherwise concentrate search work on one executor, eligible IVF queries
with enough probed partitions can also fan out partitions of that segment across
multiple executors. The segment's primary executor ranks candidate centroids
once, and the query node routes the selected IVF partitions deterministically
across the segment's executor shard pool before merging top-k candidates. Small
probe budgets and balanced multi-segment indexes continue to execute directly on
each segment's primary executor without extra coordination.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
%%{init: {"theme": "base", "themeVariables": {
  "background": "#ffffff", "primaryColor": "#ffffff", "primaryTextColor": "#221d19",
  "primaryBorderColor": "#ad9e95", "lineColor": "#6b625c", "textColor": "#221d19",
  "clusterBkg": "#f4ebe8", "clusterBorder": "#ad9e95", "edgeLabelBackground": "#ffffff",
  "fontFamily": "Inter, sans-serif", "fontSize": "18px"
}}}%%
flowchart TB
    Client["Application: vector search, limit 10"]
    QueryNode["Query node<br/>Plan, distribute, combine"]
    Index["One logical vector index<br/>Six index segments"]
    PlanExecutor1["Executor 1<br/>Cache and search segments A and B"]
    PlanExecutor2["Executor 2<br/>Cache and search segments C and D"]
    PlanExecutor3["Executor 3<br/>Cache and search segments E and F"]
    Merge["Query node<br/>Select final top 10 from up to 30 candidates"]

    Client --> QueryNode
    Index -.-> PlanExecutor1
    Index -.-> PlanExecutor2
    Index -.-> PlanExecutor3
    QueryNode -->|Search subplan| PlanExecutor1
    QueryNode -->|Search subplan| PlanExecutor2
    QueryNode -->|Search subplan| PlanExecutor3
    PlanExecutor1 -->|Up to 10 candidates| Merge
    PlanExecutor2 -->|Up to 10 candidates| Merge
    PlanExecutor3 -->|Up to 10 candidates| Merge
    Merge --> Result["Application receives up to 10 results"]
    classDef default fill:#ffffff,stroke:#ad9e95,stroke-width:1px,color:#221d19
    classDef accent fill:#fff1ec,stroke:#e8582d,stroke-width:1.5px,color:#221d19
    class Merge accent
```

### Tiered index cache

Executors cache index structures in memory, and extend that cache onto
local disk when the disk tier is enabled. See
[Tiered Index Cache](https://docs.lancedb.com/oss/v0-42-0/enterprise/tiered-index-cache.md) for how the two tiers
work together and how the disk tier's budget is shared and sized; ask your
deployment operator about enabling it on your cluster.

### Create and query an IVF-RQ index

Use the regular table API. These examples assume `table` is an open Enterprise
table with a `vector` column and the query vector is compatible with that
column. For connection setup, see [connect to
LanceDB](https://docs.lancedb.com/oss/v0-42-0/basics/catalog.md).

You can create an index before filling a vector column, including an all-NULL
Function column on a populated table. The index definition is registered, but
training waits until enough non-NULL vectors exist (`IVF_PQ` also needs enough
vectors to train its codebook). Refresh the Function to populate its output;
automatic index maintenance then trains the index. Index statistics report
`num_indexed_rows=0` until rows are indexed. Check this count before relying on
index coverage.

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
from lancedb.index import IvfRq

table.create_index("vector", config=IvfRq(num_bits=5, distance_type="cosine"))

# Run after the background index build is complete.
results = table.search(query_vector).distance_type("cosine").limit(10).to_arrow()
```

```typescript TypeScript icon="square-js" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
import { Index } from "@lancedb/lancedb";

await table.createIndex("vector", {
  config: Index.ivfRq({ numBits: 5, distanceType: "cosine" }),
});

// Run after the background index build is complete.
const results = await table
  .vectorSearch(queryVector)
  .distanceType("cosine")
  .limit(10)
  .toArray();
```

```rust Rust icon="rust" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
use futures::TryStreamExt;
use lancedb::index::{vector::IvfRqIndexBuilder, Index};
use lancedb::query::{ExecutableQuery, QueryBase};
use lancedb::DistanceType;

table
    .create_index(
        &["vector"],
        Index::IvfRq(
            IvfRqIndexBuilder::default()
                .num_bits(5)
                .distance_type(DistanceType::Cosine),
        ),
    )
    .execute()
    .await?;

// Run after the background index build is complete.
let results: Vec<arrow_array::RecordBatch> = table
    .vector_search(&query_vector)?
    .distance_type(DistanceType::Cosine)
    .limit(10)
    .execute()
    .await?
    .try_collect()
    .await?;
```

Enterprise builds FTS, vector, and scalar indexes in the background. For
first-time creation, the index appears in listings only after a worker publishes
it. During replacement, the existing index keeps serving with its current
settings and coverage until the replacement is published atomically. Track the
submitted indexing job's completion to determine when the replacement is ready;
coverage statistics can still describe the serving index while the job runs.
These examples explicitly select 5 bits per dimension. See the shared docs for
[RaBitQ and
`num_bits`](https://docs.lancedb.com/oss/v0-42-0/indexing/vector-index#using-rabitq), [index
creation
parameters](https://docs.lancedb.com/oss/v0-42-0/indexing/vector-index.md#build-time-parameters),
and [vector
search](https://docs.lancedb.com/oss/v0-42-0/search/vector-search.md#vector-search-with-ann-index).

For the `fast`, `normal`, and `accurate` latency/recall modes, see [tuning
`approx_mode`](https://docs.lancedb.com/oss/v0-42-0/search/vector-search#tuning-approx-mode).
The Rust SDK currently exposes that query setting; the examples above use the
default mode.

## Distributed full-text search

FTS work is organized by inverted index and fragment ownership. Compatible
single-column operations execute together on executors over that index's
segments. Eligible compound, cross-column (`Boolean` and `Boost`), and hybrid
(indexed segments plus unindexed tail fragments) queries also execute directly
on executors over disjoint fragment ownership sets:

1. The query node assigns each fragment to a single executor, preserving index
   segment placement and data-file page cache affinity.
2. Each executor task evaluates the query over its assigned segments or owned
   fragments and returns at most `limit` top candidates (in global scoring mode,
   mask-budget chunking can split an executor's segments into multiple tasks,
   each returning up to `limit` candidates).
3. The query node merges the bounded candidate streams with deterministic
   `(_score DESC, _rowid ASC)` ordering and applies the final top-k.

For queries whose subtrees cannot be partitioned across executors (such as
unsupported corpus shapes or legacy executor fleets), operations fall back to
separate per-index executor searches or native query-node execution.

### Local and global scoring

Distributed FTS defaults to **local scoring**. For indexed and compound
searches, each executor uses statistics from its assigned segments—or, when an
eligible large or skewed multi-partition segment is split across executors by
its physical postings partitions, from that executor's assigned postings
partitions—and its assigned unindexed fragments (for hybrid or partial-index
queries) to calculate BM25 scores. This executes in a single search round
without a statistics barrier, though document frequencies and average document
lengths can differ between executors, so merging their scores can produce a
different ranking from scoring with statistics across the entire index.

**Global scoring** adds a statistics round before search so every executor
scores with consistent corpus-wide BM25 statistics:

* For indexed and cross-column searches, the query node gathers document counts,
  token counts, and query-term document frequencies per column across all
  committed index segments.
* For hybrid and partial-index compound searches whose unindexed residual
  fragments span multiple executors, the statistics round also gathers
  per-executor residual token statistics in parallel and seeds each executor
  with the combined committed and peer-residual statistics.

The statistics remain per-column rather than blended across different text
columns. Both modes merge bounded per-executor results on the query node; global
mode does not rescore returned rows on the query node.

When term frequencies and document lengths are similarly distributed across
index segments, local scoring can produce rankings comparable to global scoring.
If segments contain substantially different document populations, prefer global
scoring for consistent statistics across the index, at the cost of an additional
statistics round and higher query latency.

Eligible flat searches over entirely unindexed text also use this setting. In
**local mode**, the scoring corpus is split by ownership of table data. Each
executor computes BM25 statistics over its assigned documents before candidate selection,
then returns matching rows. This takes one FTS execution round without a global
statistics barrier; the query node applies the final top-k. Changing executor
ownership can change scores and ranking even when the table data is unchanged.

In **global mode**, eligible unindexed flat searches and partially indexed
(mixed) searches use a two-phase protocol across executors that preserves exact
corpus-wide BM25 statistics. In phase 1, each owning executor streams its
assigned flat shards (and any participating index segments) to collect document
counts, token counts, per-term document frequencies, and bounded sparse match
locations; the query node aggregates these into one exact global BM25 scorer. In
phase 2, only executors with matching documents and admitted candidates run
streaming scoring (and per-executor top-k when applicable) under that shared
scorer before the query node merges the final top-k. When a pure flat search
maps to a single executor with no separate indexed seed or non-separable
candidates, it keeps a single-pass single-executor fast path without a separate
statistics round. Inputs that cannot be safely partitioned retain their complete
scoring domain on a single executor, and if executor capabilities (such as
rolling upgrades with older executors) or routing are unavailable, execution
falls back cleanly to a single executor or the query node.

Global scoring is a query node setting, configured at the deployment level.

See [full-text search](https://docs.lancedb.com/oss/v0-42-0/search/full-text-search.md) for
query syntax and [FTS indexes](https://docs.lancedb.com/oss/v0-42-0/indexing/fts-index.md) for
index configuration.

## Distributed data search

A table can be larger than any single node's local storage. Enterprise keeps the
durable table in object storage and distributes data reads and caches across
executors. An executor needs capacity for its cached working set rather
than a complete local copy of the table.

With fragment-based data routing, reads for a data fragment go to a serving
executor. Different fragments can be served and cached on different
executors. The following example shows six fragments served by three
executors:

```mermaid theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
%%{init: {"theme": "base", "themeVariables": {
  "background": "#ffffff", "primaryColor": "#ffffff", "primaryTextColor": "#221d19",
  "primaryBorderColor": "#ad9e95", "lineColor": "#6b625c", "textColor": "#221d19",
  "clusterBkg": "#f4ebe8", "clusterBorder": "#ad9e95", "edgeLabelBackground": "#ffffff",
  "fontFamily": "Inter, sans-serif", "fontSize": "18px"
}}}%%
flowchart TB
    QueryNode["Query node<br/>Plan data reads and assemble results"]
    PlanExecutor1["Executor 1<br/>Read fragments 1 and 2<br/>Local NVMe disk cache"]
    PlanExecutor2["Executor 2<br/>Read fragments 3 and 4<br/>Local NVMe disk cache"]
    PlanExecutor3["Executor 3<br/>Read fragments 5 and 6<br/>Local NVMe disk cache"]
    Store[("Object storage<br/>Durable table fragments")]

    QueryNode -->|Read subplan| PlanExecutor1
    QueryNode -->|Read subplan| PlanExecutor2
    QueryNode -->|Read subplan| PlanExecutor3
    PlanExecutor1 -->|Cache miss| Store
    PlanExecutor2 -->|Cache miss| Store
    PlanExecutor3 -->|Cache miss| Store
    classDef default fill:#ffffff,stroke:#ad9e95,stroke-width:1px,color:#221d19
    classDef accent fill:#fff1ec,stroke:#e8582d,stroke-width:1.5px,color:#221d19
    class Store accent
```

### NVMe data caching

The data page cache stores pages read from table fragments on **local disk,
including NVMe SSDs**. On a cache hit, the executor reads the page from
local disk; on a miss, it fetches the page from object storage and fills the
cache for subsequent reads. The cache holds accessed pages, not necessarily
every byte of each fragment assigned to an executor. See
[Data Page Cache](https://docs.lancedb.com/oss/v0-42-0/enterprise/data-page-cache.md) for how it's structured and
sized.

## Inspect execution

Use `analyze_plan()` (`analyzePlan()` in TypeScript) to understand how a query
executes and troubleshoot slow searches. It runs the query and returns the
execution plan with runtime metrics. Using the same table and query vector as
above:

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
query = table.search(query_vector).distance_type("cosine").limit(10)
print(query.analyze_plan())
```

```typescript TypeScript icon="square-js" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
const query = table.vectorSearch(queryVector).distanceType("cosine").limit(10);
console.log(await query.analyzePlan());
```

```rust Rust icon="rust" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
use lancedb::query::{ExecutableQuery, QueryBase};
use lancedb::DistanceType;

let query = table
    .vector_search(&query_vector)?
    .distance_type(DistanceType::Cosine)
    .limit(10);
println!("{}", query.analyze_plan().await?);
```

Inspect the plan to check which indexes are used, which operations run on query
nodes or executors, and where execution time is spent. Compare index
search with data retrieval to identify expensive work. Repeating the query can
also help distinguish cold-cache reads from warm-cache performance.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.