Skip to main content
VeloDB Cloud 26.x is based on Apache Doris 4.x. See Version Mapping.

Async Materialized View Overview

An async materialized view stores the results of a query in a VeloDB Cloud warehouse. You can query those results directly, or let the optimizer rewrite eligible queries to use them. Refresh runs separately from base table writes, so the stored results can lag behind the base tables.

This guide describes Core 26.1.3. See the Core release notes for the release status and changes. Creating and refreshing a materialized view uses warehouse compute and storage. Choose a refresh schedule that matches your freshness needs and billing considerations.

Quick tour​

Before using async materialized views, confirm the following points:

  • Does the business need query acceleration, ETL simplification, lakehouse external table acceleration, or write optimization?
  • Does the query match a supported rewrite pattern, such as SELECT-PROJECT-JOIN-GROUP-BY (SPJG), a matching window function, or an eligible TopN query?
  • Can the data tolerate eventual consistency (non-real-time synchronization)?
  • Is the Catalog of the base table within the supported scope (Internal/Hive/Iceberg/Paimon/Hudi/JDBC/ES)?
  • Is partitioned incremental refresh needed to lower refresh costs?

Use cases​

Async materialized views mainly target the following four scenarios:

ScenarioValue
Query acceleration and concurrency improvementReuses precomputed results to avoid repeating eligible query work
Simplified ETL workflowStores transformation results for reuse in downstream queries
Accelerated lakehouse external table queriesQueries precomputed warehouse data instead of repeatedly scanning external sources
Improved write efficiencyMoves reusable transformations into scheduled refresh tasks, with freshness and compute tradeoffs

Limitations​

Before using async materialized views, be aware of the following limitations:

  • Data consistency: An async materialized view is eventually consistent with the base table, but it cannot synchronize in real time and does not guarantee real-time consistency.
  • Window functions: Transparent rewrite requires matching window definitions and compatible predicates. See Window function rewrite.
  • Multi-table scenarios: If the materialized view joins more tables than the query involves (for example, the query only involves t1 and t2, while the materialized view contains t1, t2, and t3), transparent rewriting is currently not supported.
  • Query shape: Creating a materialized view does not guarantee that a query can use it for transparent rewrite. Materialized view definitions containing UNION ALL or CROSS JOIN are not supported by the structural rewrite rules. LIMIT and TopN queries have specific ordering, row-range, and predicate requirements. See Limit and TopN rewrite and use EXPLAIN to check the chosen plan.
  • Data type restrictions: Creating a materialized view does not currently support the VARBINARY type.

Principles​

An async materialized view is essentially an internal table of type MTMV. When the materialized view is created, the system also registers a refresh task. When the task runs, it writes the latest data into the materialized view through an INSERT OVERWRITE statement.

Refresh mechanism​

Unlike the real-time incremental refresh of synchronous materialized views, async materialized views provide more flexible refresh options:

Refresh ModeDescriptionApplicable Scenarios
Full refreshRecomputes all data referenced by the materialized view definition SQL and writes it into the materialized view in fullSmall data volume or a refresh that must recompute the entire result
Partitioned incremental refreshIdentifies supported changes in base table partition data and refreshes only the affected partitionsLarge data volume with changes concentrated in specific partitions
  • Full refresh: Recomputes the query over the source data visible to the refresh task. It can consume more compute resources and time, and later writes can make the results stale again.
  • Partitioned incremental refresh: Recomputes affected partitions rather than individual changed rows. It can reduce refresh work when changes are concentrated in a subset of partitions.

Transparent rewriting​

Transparent rewriting is an important means by which a database optimizes query performance. When processing a user query, the system automatically rewrites the SQL to hit a suitable materialized view, thereby improving execution efficiency and reducing computation costs. This does not require changing the query SQL.

The optimizer uses query structure, including the SPJG (SELECT-PROJECT-JOIN-GROUP-BY) pattern, to find eligible materialized views:

  1. Performs in-depth analysis of the structural information of the SQL.
  2. Automatically finds and selects a suitable materialized view for transparent rewriting.
  3. When multiple candidate materialized views exist, uses the cost model to compare eligible rewritten plans with other query plans.

Create an async materialized view on a data lake​

The syntax for creating an async materialized view on a data lake is identical to creating one on an internal table, but note the following:

  • Metadata source: The partition version and other information required for materialized view refresh come from the metadata cache of the data lake, not directly from the external environment. Therefore, after the refresh completes, the data is consistent with the result of querying the data lake through the warehouse, but it may be inconsistent with the results from other engines, depending on how the cache has been refreshed.
  • External change awareness: If the underlying Hive data is changed by an external process not controlled by the warehouse (such as a Spark, Hive, or Flink job) but the metadata does not change (for example, when insert overwrite is executed), the materialized view will incorrectly consider itself consistent with the base table, but the query results will be inconsistent with the results of querying the data lake through the warehouse. This issue can be resolved by manually forcing a refresh of the materialized view.
  • Iceberg limitations: When creating a partitioned materialized view on Iceberg, only Iceberg tables with a single partition column are supported, and partition evolution is supported to a limited extent. For example, time transforms can change between year, month, day, and hour while retaining the same source column. If the partition source column changes, the materialized view refresh fails.
  • Hudi limitations: When creating a materialized view on Hudi, the system cannot detect whether the base table data has changed. Use a forced full refresh (COMPLETE) or refresh explicitly named partitions after known data changes. Do not rely on AUTO to detect those changes.

Materialized view refresh support on data lakes​

The following table shows the level of refresh support for different table types and Catalogs:

Table Type Catalog Type Refresh Method Refresh Trigger
Full Refresh Partitioned Refresh Auto Trigger
Internal Table Internal Supported Supported Supported
Hive Hive Supported Supported Not supported
Iceberg Iceberg Supported Supported Not supported
Paimon Paimon Supported Supported Not supported
Hudi Hudi Supported Supported for explicit partition refresh Not supported
JDBC JDBC Supported Not supported Not supported
ES ES Supported Not supported Not supported

Transparent rewriting support on data lakes​

The transparent rewriting feature of async materialized views currently supports the following table types and Catalogs.

Note:

Change tracking compares base table versions or external metadata with the snapshots recorded during refresh. It does not refresh the materialized view in real time. External metadata caches can lag behind changes made by other engines.

Table Type Catalog Type Transparent Rewriting Support Change Tracking
Internal Table Internal Supported Supported
Hive Hive Supported Supported
Iceberg Iceberg Supported Supported
Paimon Paimon Supported Supported
Hudi Hudi Supported Not supported
JDBC JDBC Supported Not supported
ES ES Supported Not supported

Enable transparent rewriting for external table materialized views​

When a materialized view uses external tables, it does not participate in transparent rewriting by default. To enable it, run:

SET materialized_view_rewrite_enable_contain_external_table = true;

Optimize external table transparent rewriting​

For slow planning of queries that use materialized views on external tables, check metadata freshness and cache behavior. VeloDB Cloud manages frontend configuration for both SaaS and BYOC warehouses. Contact VeloDB Cloud support before changing service settings.

The following values are compiled Core 26.1.3 references, not a measurement of your warehouse settings:

Managed parameterCore reference valuePurpose
max_hive_partition_cache_num10000 entriesMaximum cached Hive partition metadata objects. The appropriate capacity depends on the number of partitions and available frontend memory.
external_cache_expire_time_seconds_after_access86400 seconds (24 hours)Expires external metadata cache objects after their last access.
external_cache_refresh_time_minutes10 minutesRefreshes applicable external metadata cache objects. Increasing the interval can reduce metadata requests but can delay discovery of source changes.

For more configuration details on external table metadata cache, see Metadata Cache.

Relationship between materialized views and OLAP internal tables​

There is no restriction on the base table model used in the SQL definition of an async materialized view. It can be a Duplicate model, a Unique model (merge-on-write or merge-on-read), an Aggregate model, and so on.

The underlying implementation of the materialized view itself relies on an OLAP table of the Duplicate model and can in theory support all core features of the Duplicate model. However, to ensure that the materialized view can stably and efficiently execute data refresh tasks, a series of necessary restrictions are placed on its functionality:

  • Partition operations: The partitions of a materialized view are automatically created and maintained based on its base tables. Users cannot perform partition operations on a materialized view.
  • Drop and rename: Because there are associated jobs (JOB) behind a materialized view, the DROP TABLE or RENAME TABLE commands cannot be used to operate on a materialized view. Use the materialized view's own commands to perform the corresponding operations.
  • Column data types: The column data types of a materialized view are automatically derived from the query statement specified at creation time and cannot be modified, otherwise the refresh task may fail.
  • Property modification: A materialized view has some properties that a Duplicate table does not have. These must be modified through the materialized view's commands. Other common properties are modified using the ALTER TABLE command.

FAQ​

Q1: Can an async materialized view guarantee real-time data consistency with the base table?

No. An async materialized view is eventually consistent with the base table, but it cannot synchronize in real time. If real-time consistency is required, consider a synchronous materialized view.

Q2: Why does a query with window functions fail to use a materialized view?

The query and materialized view must have matching window definitions, and any compensated predicates must be compatible with those windows. Use EXPLAIN to inspect the rewrite result. See Window function rewrite.

Q3: Why is a materialized view based on an external table not hit by rewriting?

External-table-based materialized views do not participate in transparent rewriting by default. Set materialized_view_rewrite_enable_contain_external_table = true to make them participate in rewriting.

Q4: Why are the materialized view query results inconsistent after Hive external table data is modified by an external process?

If Hive data is modified by an external process such as Spark, Hive, or Flink but the metadata does not change (for example, insert overwrite), the materialized view cannot detect the change. This can be resolved by manually forcing a refresh of the materialized view.

Q5: Can a materialized view based on Hudi refresh automatically?

It cannot detect changes in the base table. Use COMPLETE or explicitly refresh the affected partitions after known source changes.

See also​