REFRESH statement updates the stored query results of a materialized view.
CockroachDB does not support materialized views that are refreshed on transaction commit.
Required privileges
The user must be the owner of the materialized view or have admin privileges.Synopsis
Parameters
Use historical data when refreshing the view. This can reduce contention by leveraging follower reads. The timestamp must be within the garbage collection window. For more information, see
AS OF SYSTEM TIME.
Examples
The following example uses the samplebank database, populated with some workload values.
Suppose that you create a materialized view on the bank table:
balance values of the bank table:
SELECT statement against the table:
overdrawn_accounts returns stored results, which are outdated:
REFRESH statement:
Refresh a materialized view with historical data using AS OF SYSTEM TIME
New in v25.2: You can refresh a materialized view using historical data with the AS OF SYSTEM TIME clause. This is useful for reducing contention by performing a follower read when refreshing the view.
Historical data is available only within the garbage collection window.
follower_read_timestamp() to use the most recent data that is available for follower reads:

