Hello! Welcome back to our module on Modern Cloud Data Warehousing.
In our last lesson, we explored how to optimize the physical layout of our data using partitioning and clustering. These techniques are powerful because they help the query engine read less data from disk. Today, we'll add another crucial optimization tool to your architectural toolkit: pre-computation.
Your learning outcome is to create materialized views to accelerate common analytical queries. Instead of organizing data for faster reads, materialized views work by pre-calculating and storing the results of slow, repetitive queries. For an architect, understanding when to use this technique is a key part of designing systems that are both fast and cost-effective, especially when powering business-critical dashboards and reports.
1. What is a Materialized View?
At its core, a materialized view is a database object that stores the result of a query. Think of it as a physical table that contains pre-computed data.
Unlike a standard view, which is just a stored query definition that runs every time you access it, a materialized view physically "materializes" the results to disk. When the data in the underlying source tables changes, the materialized view can be refreshed to reflect those changes.
This image neatly illustrates the concept:

Let's dive into the specifics of what this means in a modern cloud data warehouse like BigQuery.
Optimize Query Performance with BigQuery Views in 2025
To start, let's get a clear definition of materialized views and their main benefits from an article by OWOX BI.
Please read the sections 'What Are Materialized Views in BigQuery?' and 'Benefits of Using Materialized Views for Query Performance'. Focus on how they improve performance and reduce costs by caching results.
As you just read, the primary benefits are clear:
- Improved Query Performance: By querying pre-computed results, response times can drop from minutes to seconds.
- Reduced Query Costs: In platforms that charge per byte scanned (like BigQuery), querying a small, aggregated materialized view is far cheaper than scanning a massive base table.
- Optimized Resource Usage: The warehouse does less work for each query, freeing up computational resources for other tasks.
2. Materialized Views vs. Standard Views: The Key Trade-Off
Your experience as a software architect will make the distinction between a standard view and a materialized view intuitive. A standard view is like a saved shortcut or a macro—it's just a logical definition. A materialized view is more like a cache—it's a physical copy of the data, optimized for fast retrieval.
This difference leads to a fundamental trade-off between performance, cost, and data freshness.
Optimize Query Performance with BigQuery Views in 2025
The following resource provides an excellent table that breaks down the differences between standard and materialized views. This comparison is central to deciding which to use.
Read the section 'Understanding Materialized Views vs. Standard Views in BigQuery'. Pay close attention to the comparison table, which highlights the key differences in data storage, performance, cost, and typical usage scenarios.
To summarize the architectural trade-off:
- Standard Views guarantee fresh data but can be slow and expensive for complex queries. They are best for ad-hoc analysis where real-time data is essential.
- Materialized Views provide high performance at a low query cost but introduce storage costs and a delay in data freshness (latency). They are best for repetitive, predictable queries that power dashboards and reports where sub-second response is critical.
3. Creating and Using a Materialized View
Now, let's look at how you actually create one. The syntax is very similar to creating a standard table or view. You define the view with a SELECT statement that performs the join, aggregation, or transformation you want to accelerate.

The syntax in most modern data warehouses is straightforward. Here is how you would create a materialized view in BigQuery or Snowflake (with minor dialect differences):
CREATE MATERIALIZED VIEW project.dataset.daily_summary AS
SELECT
DATE_TRUNC(sale_date, DAY) AS sale_day,
product_category,
SUM(sales_amount) AS total_sales,
COUNT(DISTINCT customer_id) AS unique_customers
FROM
project.dataset.sales_fact
GROUP BY
1, 2;
Once created, you can query this view just like any other table:
SELECT * FROM project.dataset.daily_summary WHERE sale_day = '2023-10-26';
This query will be extremely fast because all the SUM and COUNT aggregations have already been done.
Test your understanding!
You have a transactions fact table and a stores dimension table. Your operations team frequently runs a query to get the total daily transaction count for each store region. The query is slow because it joins the tables and aggregates millions of transaction records every time.
Write the CREATE MATERIALIZED VIEW statement for a view named daily_regional_transactions that would pre-compute this result. The view should contain three columns: transaction_date, store_region, and transaction_count.
Show answer
CREATE MATERIALIZED VIEW daily_regional_transactions AS
SELECT
DATE(t.transaction_timestamp) AS transaction_date,
s.store_region,
COUNT(t.transaction_id) AS transaction_count
FROM
transactions t
JOIN
stores s ON t.store_id = s.store_id
GROUP BY
1, 2;
This view pre-calculates the aggregation, so queries against daily_regional_transactions filtered by date or region will be much faster.
4. The "Magic" of Modern Materialized Views
In traditional systems, managing materialized views could be a chore, requiring manual refresh schedules. Modern cloud data warehouses have made them much more powerful and easier to use through two key features:
- Automatic Refresh: The warehouse can detect when the underlying base tables have changed and automatically trigger a refresh of the materialized view. This is often done incrementally, only processing the new or changed data, making it very efficient.
- Automatic Query Rewriting: This is the most impressive part. The query optimizer is smart enough to recognize when a query submitted against a base table can be satisfied by an existing materialized view. When it detects this, it automatically rewrites the query on the fly to use the faster materialized view, without the user having to change their query at all.
This article snippet illustrates the query rewriting concept perfectly.
SQL Optimization for Cloud Data Warehouses - Marlene
Let's see an example of automatic query rewriting in action. The user queries the base table, but the system is smart enough to use the materialized view instead.
Read the code block under 'Materialized Views for Repetitive Patterns'. Notice how the materialized view customer_monthly_summary is created. Then look at the query below it, which queries the base table sales_fact. The comment highlights that the warehouse can automatically rewrite this query to use the much faster materialized view.
This intelligence removes a significant management burden and allows architects to create optimization structures that benefit all users transparently.
Conclusion
You've now learned about materialized views, a powerful pre-computation strategy to complement the physical layout optimizations of partitioning and clustering. As a data architect, you'll use materialized views to solve some of the most common performance bottlenecks in analytics.
Key Takeaways:
- Materialized views store the pre-computed results of a query on disk, trading storage cost for dramatically faster query performance.
- They are fundamentally different from standard views, which are simply stored query definitions.
- The primary use case is accelerating repetitive, expensive aggregation queries, such as those that power BI dashboards and operational reports.
- Modern cloud data warehouses simplify their use through automatic refresh and automatic query rewriting, making them a highly effective optimization tool.
In our previous lessons, we've focused on optimizing a single data warehouse. But architecture is often about choosing the right tool for the job. In our next lesson, we will compare the use cases for a cloud data warehouse versus a data lakehouse, which will broaden our perspective to system-level architectural patterns.