From eaa160c1b7a047729d45d99069be465eefef7993 Mon Sep 17 00:00:00 2001 From: ChilePiquin Date: Sat, 14 Nov 2026 07:18:37 -0800 Subject: [PATCH] docs: clarify prewarm modes and publish SDK examples --- docs/src/js/classes/Table.md | 42 +++++++++++- docs/src/js/globals.md | 1 + docs/src/js/interfaces/PrewarmDataOptions.md | 39 +++++++++++ docs/web/enterprise/cache-prewarm.mdx | 72 ++++++++++++++++---- 4 files changed, 138 insertions(+), 16 deletions(-) create mode 100644 docs/src/js/interfaces/PrewarmDataOptions.md diff --git a/docs/src/js/classes/Table.md b/docs/src/js/classes/Table.md index 3150d94ec..37686a77e 100644 --- a/docs/src/js/classes/Table.md +++ b/docs/src/js/classes/Table.md @@ -1060,8 +1060,8 @@ Prewarm one or more columns of data in the table. This will load the column data into the page cache so that future queries that read those columns avoid the initial cold-start latency. This call initiates prewarming and returns once the request is accepted; the warming itself may - continue in the background. Calling it on already-prewarmed columns is a - no-op on the server. + continue in the background. Submission uses SQL PREWARM and needs Flight + SQL connectivity. Use [prewarmDataAsync](Table.md#prewarmdataasync) to retain the job handle. Prewarming is generally useful for columns used in filters or projections. Large columns (e.g. high-dimensional vectors or binary data) may not be practical to prewarm. @@ -1073,6 +1073,44 @@ Prewarm one or more columns of data in the table. *** +### prewarmDataAsync() + +```ts +abstract prewarmDataAsync(options?): Promise +``` + +Submit data prewarm through SQL and return its durable warming-job handle. + +The table handle supplies the branch and namespace. Requires a compatible +SQL PREWARM server and Flight SQL connectivity. Standard authorization +requires table Select and database/namespace Usage. Status/wait use generic +HTTP job APIs; events and cancellation retain their own privileges. +No REST fallback or option-dropping retry is performed. Historical-version +handles are unsupported; call `checkoutLatest()` first. + +Submission returns after acceptance. Use `job.wait()` for completion, or +save `job.id` and reopen it with `db.openJob(id)`. A timeout does not cancel +the job. After `job.refresh()`, `job.spec.table_version` is the pinned version. + +#### Parameters + +* **options?**: [`PrewarmDataOptions`](../interfaces/PrewarmDataOptions.md) + +#### Returns + +`Promise`<[`Job`](Job.md)> + +#### Example + +```ts +const job = await table.prewarmDataAsync({ + columns: ["video"], filter: "quality > 0.7", concurrency: 4, +}); +await job.wait(); +``` + +*** + ### prewarmIndex() ```ts diff --git a/docs/src/js/globals.md b/docs/src/js/globals.md index beed7c8af..44094dcd6 100644 --- a/docs/src/js/globals.md +++ b/docs/src/js/globals.md @@ -125,6 +125,7 @@ - [OpenTableOptions](interfaces/OpenTableOptions.md) - [OptimizeOptions](interfaces/OptimizeOptions.md) - [OptimizeStats](interfaces/OptimizeStats.md) +- [PrewarmDataOptions](interfaces/PrewarmDataOptions.md) - [QueryExecutionOptions](interfaces/QueryExecutionOptions.md) - [RTEStats](interfaces/RTEStats.md) - [RTEWriteSpec](interfaces/RTEWriteSpec.md) diff --git a/docs/src/js/interfaces/PrewarmDataOptions.md b/docs/src/js/interfaces/PrewarmDataOptions.md new file mode 100644 index 000000000..def1eb822 --- /dev/null +++ b/docs/src/js/interfaces/PrewarmDataOptions.md @@ -0,0 +1,39 @@ +[**@lancedb/lancedb**](../README.md) • **Docs** + +*** + +[@lancedb/lancedb](../globals.md) / PrewarmDataOptions + +# Interface: PrewarmDataOptions + +Settings for submitting a durable remote data-cache prewarm job. + +## Properties + +### columns? + +```ts +optional columns: string[]; +``` + +Lance field paths to warm; omitted or empty means every column. + +*** + +### concurrency? + +```ts +optional concurrency: number; +``` + +Positive per-executor concurrency, at most 4294967295. + +*** + +### filter? + +```ts +optional filter: string; +``` + +A single SQL predicate for conservative metadata pruning. diff --git a/docs/web/enterprise/cache-prewarm.mdx b/docs/web/enterprise/cache-prewarm.mdx index b93580bfa..c3ca9f8e8 100644 --- a/docs/web/enterprise/cache-prewarm.mdx +++ b/docs/web/enterprise/cache-prewarm.mdx @@ -1,23 +1,25 @@ --- title: "Cache Prewarm" sidebarTitle: "Cache Prewarm" -description: "Populate the tiered index cache ahead of a request, instead of filling it lazily on first read." +description: "Warm indexes at executor startup or submit on-demand jobs to populate the data page cache." icon: "fire" -keywords: ["prewarm", "cache", "index cache", "startup"] +keywords: ["prewarm", "cache", "index cache", "data page cache", "startup"] availability: embedded: unavailable enterprise: available --- -Cache Prewarm loads the [tiered index cache](/enterprise/tiered-index-cache) -a plan executor keeps as part of Enterprise's serving layer, instead of -leaving it to fill lazily on first read. You configure which tables to -prewarm; on startup, each plan executor loads those tables' indexes into -cache before it joins the fleet. The executor does not accept queries until -prewarming finishes, so it never serves a request against a cold cache. +Enterprise supports two kinds of cache prewarm: startup index prewarm fills +the [tiered index cache](/enterprise/tiered-index-cache), and +[on-demand data prewarm](#on-demand-data-prewarm) fills the +[data page cache](/enterprise/data-page-cache) through a durable job. -LanceDB Embedded has no such cache, so there is nothing for it to warm -there. Embedded does have its own, separate `prewarm_index()` on a table -- +For startup index prewarm, you configure which tables to warm. Each plan +executor loads those tables' indexes before it joins the fleet. The executor +does not accept queries until startup prewarming finishes. + +These Enterprise caches are not available in LanceDB Embedded. +Embedded does have its own, separate `prewarm_index()` on a table -- an idempotent hint that loads a built index into memory ahead of a query.
@@ -72,7 +74,7 @@ and rollouts instead of dipping right after each one. [Contact us](https://www.lancedb.com/contact) to learn more about how prewarming is configured for your deployment. -## On-demand data prewarm +## On-demand data prewarm {#on-demand-data-prewarm} On compatible Enterprise deployments, the SDK submits data prewarm through SQL. Flight SQL connectivity is required; the existing generic HTTP job API is @@ -81,10 +83,13 @@ authorization, submission requires table Select plus Usage on the database and namespace hierarchy. Job events require System Usage and cancellation requires System Operate. +The table handle determines the database, namespace, and branch in every SDK. + + + ```python from datetime import timedelta -# The table handle determines the database, namespace, and branch. job = table.prewarm_data_async( ["video"], filter="quality > 0.7", concurrency=4 ) @@ -94,6 +99,45 @@ job.wait(timeout=timedelta(minutes=10)) # Reattach in a later process using the same database connection settings. db.open_job(job.id).wait() ``` + + +```typescript +const job = await table.prewarmDataAsync({ + columns: ["video"], + filter: "quality > 0.7", + concurrency: 4, +}); +console.log(job.id); +await job.wait(); + +// Reattach using the same database connection settings. +if (job.id !== null) { + await (await db.openJob(job.id)).wait(); +} +``` + + +```rust +use lancedb::table::PrewarmDataOptions; + +let job = table + .prewarm_data_async( + PrewarmDataOptions::new() + .columns(["video"]) + .filter("quality > 0.7") + .concurrency(4), + ) + .await?; +println!("{:?}", job.id()); +job.wait().await?; + +// Reattach using the same database connection settings. +if let Some(id) = job.id() { + db.open_job(id).await?.wait().await?; +} +``` + + The method returns when the job is accepted. Waiting finishes when warming reaches a terminal state; a timeout does not cancel the job. Use @@ -118,10 +162,10 @@ already-cached data is safe. Index prewarm keeps its existing behavior. - The raw-data-page cache -- a separate cache from the one prewarm fills. + The raw-data-page cache populated by on-demand data prewarm jobs. - The deserialized-index cache prewarm fills. + The deserialized-index cache populated by startup index prewarm. Where plan executors and query nodes sit in the serving fleet.