> ## 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.

# Refresh a materialized view

> Bring a materialized view up to date after its source data changes.

**Applies to:** Embedded ❌, Enterprise ✅

Refresh a [materialized view](https://docs.lancedb.com/feature-engineering/materialized-views.md) to
bring its stored rows up to date after the source table changes.

> [!NOTE]
>
> In SQL this is [`REFRESH MATERIALIZED VIEW`](https://docs.lancedb.com/sql/dml/refresh-materialized-view).

## Refresh a view

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
view.refresh()
```

In LanceDB Embedded, every refresh rebuilds the view completely from its
source query -- there is no incremental refresh there. Calling it again
with no source changes still rebuilds and commits a new table version. In
LanceDB Enterprise, the server chooses the refresh mode instead; pass
`full=True` to force a full rebuild there too.

In LanceDB Embedded, the result reports what the refresh did:

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
result = view.refresh()
result.rows_written  # rows in the rebuilt view
result.source_version  # the source table version the view now reflects
result.version  # the view's own new table version
```

LanceDB Enterprise refreshes run through its SQL job adapter, which doesn't
expose these metrics: `mode`, `rows_written` and `source_version` are all
`None` on an Enterprise result, even though the refresh itself ran.

Pass `source_version=N` to refresh against a particular source version
instead of the latest. This is a LanceDB Embedded capability only --
LanceDB Enterprise's SQL refresh does not support pinning a source version:

```python Python icon="python" theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
view.refresh(source_version=12)  # LanceDB Embedded only
```

Use `view.table.count_rows()` for the view's row count at any time; on
LanceDB Embedded it always matches `rows_written` from the most recent
refresh.

## Automatic refresh

A materialized view can refresh itself on a schedule instead of waiting
for an explicit `refresh()` call. See [Auto Refresh](https://docs.lancedb.com/enterprise/auto-refresh.md)
for enabling it at creation, the SQL and SDK forms for changing the
setting afterward, and how it differs from a computed column's
per-output granularity.

## When a refresh fails

A refresh replaces the view's stored rows in one commit, so a failure leaves
the view as it was after its last successful refresh. Fix the cause and
refresh again.

## Related guides

> [card] [Create a materialized view](https://docs.lancedb.com/feature-engineering/materialized-views.md)
>
> Define the query a view stores.

> [card] [Refresh a computed column](https://docs.lancedb.com/feature-engineering/refresh-column.md)
>
> The same idea, for a single derived column.

> [card] [Auto Refresh](https://docs.lancedb.com/enterprise/auto-refresh.md)
>
> Refresh on a schedule instead of calling this yourself.


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