mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 20:44:00 +00:00
BREAKING CHANGE: Resource inputs use the same names at Function
registration, column/MV creation, and refresh. Use total_cpu_millis,
total_memory_bytes, and total_gpu_count for execution-wide worker
budgets, plus gpu_class and positive gpu_count for each worker. Replace
budget dictionary inputs and unprefixed aggregate limits with these
fields. Move existing refresh gpu_count caps to total_gpu_count;
gpu_count now selects devices per worker.
Each setting resolves independently: refresh > column/MV creation >
Function annotation > deployment. Creation settings also apply to
initial MV population and automatic refresh. MVs sum total budgets
across distinct pinned Function versions; per-worker GPU counts use the
largest Function default unless overridden. An unset GPU class resolves
to gpu_class="any" after inheritance; an explicit "any" overrides a
registered concrete class. Use gpu_class="default" to pin the default
pool explicitly.
```python
@function(
gpu=True, gpu_class="h100", gpu_count=2,
total_cpu_millis=8000,
total_memory_bytes=16 * 1024**3,
total_gpu_count=4,
)
def embed(text: str) -> list[float]: ...
version = db.create_function(embed)
table.add_columns(
{"embedding": version(text=col("text"))},
gpu_class="any", gpu_count=1, total_gpu_count=8,
)
table.refresh_column_async(
"embedding", gpu_class="h100", gpu_count=4, total_gpu_count=8,
)
mv = db.create_materialized_view(
"embeddings", query="SELECT embed(text) AS embedding FROM documents",
gpu_class="any", gpu_count=2, total_gpu_count=8,
)
mv.refresh(gpu_count=4, total_gpu_count=8)
```
```mermaid
flowchart TD
R["Refresh settings"] --> E["Effective settings, resolved per field"]
D["Column or MV creation settings"] --> E
F["Function settings"] --> E
C["Deployment defaults"] --> E
E --> W["GPU class and device count per worker"]
E --> T["Total CPU, memory and GPU ceilings"]
```
Pinned Function images retain their identity. Registration GPU counts
are defaults; execution overrides determine worker allocation. Admission
rejects GPU counts below an image's minimum requirement or above the
total budget. Python, Rust, SQL/REST and supported TypeScript operations
use the same resource model.
No local builds or tests, as requested; regression coverage runs in CI.
93 lines
3.4 KiB
Plaintext
93 lines
3.4 KiB
Plaintext
---
|
|
title: "REFRESH MATERIALIZED VIEW"
|
|
sidebarTitle: "REFRESH MATERIALIZED VIEW"
|
|
description: "Bringing a materialized view's stored result up to date."
|
|
icon: arrows-rotate
|
|
keywords: ["refresh materialized view", "cascade"]
|
|
availability:
|
|
embedded: unavailable
|
|
enterprise: available
|
|
---
|
|
|
|
A LanceDB extension with no DataFusion equivalent.
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
REFRESH MATERIALIZED VIEW <name>
|
|
[WITH (full = <boolean>, total_cpu_millis = <integer>, total_memory_bytes = <integer>,
|
|
total_gpu_count = <integer>, gpu_class = '<class>')]
|
|
```
|
|
</CodeGroup>
|
|
|
|
<CodeGroup>
|
|
```sql SQL icon="database"
|
|
REFRESH MATERIALIZED VIEW chunks
|
|
REFRESH MATERIALIZED VIEW chunks WITH (full = true)
|
|
```
|
|
</CodeGroup>
|
|
|
|
A refresh updates the view's stored result. Refresh views in dependency order,
|
|
starting with their source views. `full = true` forces a complete rebuild
|
|
even when the sources are unchanged; the default, `false`, refreshes
|
|
incrementally when supported and rebuilds otherwise.
|
|
|
|
<Note>
|
|
`CASCADE` is not accepted by the SQL implementation described here,
|
|
regardless of what a local SDK's `refresh()` method accepts -- do not
|
|
assume the two option sets match.
|
|
</Note>
|
|
|
|
## Resource budgets {#resources}
|
|
|
|
Set budgets for one refresh execution:
|
|
|
|
```sql
|
|
REFRESH MATERIALIZED VIEW curated_training_set WITH (
|
|
total_cpu_millis = 8000,
|
|
total_memory_bytes = 17179869184,
|
|
total_gpu_count = 2,
|
|
gpu_class = 'h100'
|
|
);
|
|
```
|
|
|
|
`total_cpu_millis` is CPU capacity in millicores (1000 = one core), not CPU time.
|
|
`total_memory_bytes` caps memory in bytes. `total_gpu_count` caps concurrent GPUs for the
|
|
refresh. These are aggregate caps across its SQL execution and Function
|
|
processes; they are not multiplied by the number of Functions in the query.
|
|
|
|
Each resource may be overridden independently. CPU and memory must be positive;
|
|
`total_gpu_count = 0` is allowed for CPU-only views. A GPU budget alone is also accepted.
|
|
A cap does not reserve all of its GPUs or increase refresh parallelism. Current
|
|
MV refreshes use at most one GPU, shared by their GPU Function calls.
|
|
|
|
`gpu_class` selects an operator-configured class for this execution, leaving the
|
|
Function registration and saved MV placement unchanged. Use `SHOW GPU CLASSES`
|
|
to discover configured classes. Omitted budgets and class preserve defaults.
|
|
Options can be combined with `full = true`.
|
|
|
|
This requires an Enterprise server and an isolated execution backend that can
|
|
enforce resource budgets. Unsupported backends reject constrained refreshes.
|
|
Older servers reject the new options. Saved defaults and automatic refresh
|
|
configuration are unchanged.
|
|
|
|
## Watching a refresh {#watching}
|
|
|
|
A refresh submits work that outlives the call. Track it with
|
|
[`SHOW JOBS`](/sql/ddl/job#show), and diagnose failures with
|
|
[`SHOW ERRORS`](/sql/ddl/job#errors). For per-split progress, worker fleet
|
|
detail, and a `DESCRIBE JOB` example, see [Watching a refresh](/sql/dml/refresh#watching).
|
|
|
|
## See also {#see-also}
|
|
|
|
<CardGroup cols={2}>
|
|
<Card title="Materialized View" icon="table" href="/sql/ddl/materialized-view">
|
|
Creating the view this refreshes.
|
|
</Card>
|
|
<Card title="Refresh a materialized view" icon="layer-group" href="/feature-engineering/refresh-materialized-view">
|
|
The same operation from the SDKs, and automatic refresh.
|
|
</Card>
|
|
<Card title="REFRESH COLUMN" icon="arrows-rotate" href="/sql/dml/refresh-column">
|
|
Filling a computed column, instead of a view.
|
|
</Card>
|
|
</CardGroup>
|