Stay organized with collections Save and categorize content based on your preferences.
Introduction to materialized viewsMaterialized views are precomputed views that periodically store the results of a SQL query. Materialized views can reduce the total processing time and charges related to querying by storing query results, reducing the amount of data to be scanned for each query. BigQuery verifies that materialized views provide fresh data by computing updates in the background. This process is performed incrementally by using only the changed data in the base table, subject to a number of considerations. Materialized views can be either queried directly or used by BigQuery to optimize queries to their base tables.
Key characteristics of materialized views include the following:
Materialized views can optimize queries with high computation cost and small dataset results. Processes that benefit from materialized views include online analytical processing (OLAP) operations that require significant processing with predictable and repeated queries like those in from extract, transform, load (ETL) processes or business intelligence (BI) pipelines.
The following use cases highlight the value of materialized views. Materialized views can improve query performance if you frequently require the following:
Materialized views can be used to transparently improve the performance of queries without modifying them. You can use a materialized view to optimize sets of queries with common patterns, such as those generated by a BI tool. For more information see Use materialized views.
Comparison to other BigQuery techniquesThe following table summarizes the similarities and differences between BigQuery caching, scheduled queries, logical views, and materialized views.
Component Caching Scheduled queries Logical views Materialized views Optimize compute Yes No No Yes Query support All All All Limited1 Partitioning and clustering No Yes N/A Yes Incremental refresh No No No Yes Additional storage No Yes No Yes Query rewrite No No No Yes Maintenance costs No Yes N/A Yes Data staleness Never Yes Never Optional 21 The --allow_non_incremental_definition
option supports an expanded range of SQL queries to create materialized views.
2 The --max_staleness
option provides consistently high performance with controlled costs when processing large, frequently changing datasets.
You can create an authorized materialized view to share a subset of data from a source dataset to a view in a secondary dataset. You can then share this view to specific users and groups (principals) who can view the data you share. Principals can query the data you provide in a view, but they can't access the source dataset directly.
Authorized views and authorized materialized views are authorized in the same way. For details, see Authorized views.
Interaction with other BigQuery featuresThe following BigQuery features work transparently with materialized views:
Query plan explanation: The query plan reflects which materialized views are scanned (if any), and shows how many bytes are read from the materialized views and base tables combined.
Query caching: The results of a query that BigQuery rewrites using a materialized view can be cached subject to the usual limitations (using of deterministic functions, no streaming into the base tables, etc.).
Cost restriction: If you have set a value for maximum bytes billed, and a query would read a number of bytes beyond the limit, the query fails without incurring a charge, whether the query uses materialized views, the base tables, or both.
Cost estimation using dry run: A dry run repeats query rewrite logic using the available materialized views and provides a cost estimate. You can use this feature as a way to test whether a specific query uses any materialized views.
Materialized views over BigLake metadata cache-enabled tables can reference structured data stored in Cloud Storage and Amazon Simple Storage Service (Amazon S3). These materialized views function like materialized views over BigQuery-managed storage tables, including the benefits of automatic refresh and smart tuning. Other benefits include the pre-aggregating, pre-filtering, and pre-joining of data stored outside of BigQuery. Materialized views over BigLake tables are stored in and have all of the characteristics of BigQuery managed storage.
Note: When a materialized view over a BigLake table with cached metadata is refreshed, the materialized view's cached data contains all updates to the external table up to the most recent metadata cache creation.When you create a materialized view over an Amazon S3 BigLake table, the data in the materialized view isn't available for joins with BigQuery data. To make Amazon S3 data in a materialized view available for joins, create a replica of the materialized view. You can only create materialized view replicas over authorized materialized views.
Materialized view replicasBigQuery lets you create materialized views on BigLake metadata cache-enabled tables over Amazon Simple Storage Service (Amazon S3), Apache Iceberg, or Salesforce Data Cloud data.
A materialized view replica lets you use the Amazon S3, Iceberg, or Data Cloud materialized view data in queries while avoiding data egress costs and improving query performance. A materialized view replica does this by replicating the Amazon S3, Iceberg, or Data Cloud data to a dataset in a supported BigQuery region, so that the data is available locally in BigQuery.
Learn how to create materialized view replicas.
Data freshnessAfter you create the materialized view replica, the replication process polls the source materialized view for changes and replicates data to the materialized view replica. The data is replicated at the interval you specified in the replication_interval_seconds
option of the CREATE MATERIALIZED VIEW AS REPLICA OF
statement.
In addition to the replication interval, the freshness of the materialized view replica data is also affected by how often the source materialized view refreshes, and how often the metadata cache of the Amazon S3, Iceberg, or Data Cloud table used by the materialized view refreshes.
You can check the data freshness for the materialized view replica and the resources it is based on by using the Google Cloud console:
Use the location mappings in the following table when creating materialized view replicas:
Location of the source materialized view Location of the materialized view replicaaws-us-east-1
The US
multi-region, or any of the following regions:
northamerica-northeast1
northamerica-northeast2
us-central1
us-east1
us-east4
us-east5
us-south1
us-west1
us-west2
us-west3
us-west4
aws-us-west-2
The US
multi-region, or any of the following regions:
northamerica-northeast1
northamerica-northeast2
us-central1
us-east1
us-east4
us-east5
us-south1
us-west1
us-west2
us-west3
us-west4
aws-eu-west-1
The EU
multi-region, or any of the following regions:
europe-central2
europe-north1
europe-southwest1
europe-west1
europe-west2
europe-west3
europe-west4
europe-west6
europe-west8
europe-west9
europe-west10
aws-ap-northeast-2
Any of the following regions:
asia-east1
asia-east2
asia-northeast1
asia-northeast2
asia-northeast3
asia-south1
asia-south2
asia-southeast1
aws-ap-southeast-2
Any of the following regions:
australia-southeast1
australia-southeast2
COPY
, EXPORT
, LOAD
, WRITE
, or data manipulation language (DML) statements.1Logical view reference support is in preview. For more information, see Reference logical views.
Limitations of materialized views over BigLake tables-max_staleness
option value of the materialized view must be greater than that of the BigLake base table.Costs are associated with the following aspects of materialized views:
1Where possible, BigQuery reads only the changes since the last time the view was refreshed. For more information, see Incremental updates.
Storage cost detailsFor AVG
, ARRAY_AGG
, and APPROX_COUNT_DISTINCT
aggregate values in a materialized view, the final value is not directly stored. Instead, BigQuery internally stores a materialized view as an intermediate sketch, which is used to produce the final value.
As an example, consider a materialized view that's created with the following command:
CREATE MATERIALIZED VIEW project-id.my_dataset.my_mv_table AS SELECT date, AVG(net_paid) AS avg_paid FROM project-id.my_dataset.my_base_table GROUP BY date
While the avg_paid
column is rendered as NUMERIC
or FLOAT64
to the user, internally it is stored as BYTES
, with its content being an intermediate sketch in proprietary format. For data size calculation, the column is treated as BYTES
.
Use of materialized view replicas incurs compute, outbound data transfer, and storage costs.
What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Materialized views in BigQuery are precomputed views that cache query results, enhancing performance and efficiency by using cached data and reading only changes from base tables when possible."],["These views offer zero maintenance, automatically refreshing as base tables change, and they ensure data freshness by directly reading from base tables if changes might invalidate the view."],["Materialized views optimize queries with high computation costs and are particularly beneficial for use cases like pre-aggregating, pre-filtering, and pre-joining data, including data from BigLake tables."],["Materialized view replicas allow the use of data from external sources like Amazon S3 within BigQuery, avoiding egress costs and improving performance by replicating the data locally."],["There are costs associated with the use of materialized views, including querying, maintenance during refresh operations, and the storage of the materialized view tables."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4