Materialized views
If your big data computing tasks contain many similar subqueries, the automated governance feature in Data Asset Governance provides an intelligent solution. This feature automatically identifies and classifies similar subqueries in MaxCompute and generates materialized view recommendations. You can then create these materialized views with a single click to significantly improve computing efficiency and save compute resources.
How it works
The materialized view feature in DataWorks automated governance uses MaxCompute's Materialized View Recommendation and Management capability. It quickly scans and identifies numerous similar subqueries within MaxCompute SQL jobs in DataWorks scheduling scenarios. Based on these findings, it recommends SQL statements to help you quickly create materialized views.
After a materialized view is created, DataWorks automatically creates a node to generate the view's data and deploys it to the production environment for scheduling. Existing downstream nodes in DataWorks that contain the identified similar subqueries then depend on this new view-generating node. Due to this scheduling dependency, DataWorks runs the view-generating node first. When a downstream node executes a public subquery, it queries the pre-computed data from the materialized view. This process reduces redundant calculations and achieves governance objectives.
Supported regions: China (Hangzhou), China (Shanghai), China (Shenzhen), China (Beijing), and China (Chengdu).
Prerequisites
-
You have added a MaxCompute data source. For more information, see Bind a MaxCompute compute resource.
-
You have enabled intelligent analysis for materialized views in MaxCompute. For more information, see Materialized View Recommendation and Management.
Workflow
-
Enable materialized view recommendations.
After you enable materialized view recommendations for a MaxCompute project that is bound to a DataWorks workspace, the system generates recommendations on the materialized view recommendation page when the following conditions are met:
-
A scheduled task runs for at least three consecutive days.
-
The input data in a public subquery exceeds 1,000,000 rows.
-
The public subquery contains operators that perform data restructuring, such as JOIN or aggregation (AGG).
-
-
View recommendations and create materialized views.
You can review the materialized view recommendations to determine if they are appropriate, and then create a governance task to build the materialized view.
If you configure the Create Materialized View Refresh Node and Add Materialized View Refresh Node as Ancestor Node options during creation, the materialized view becomes active in your DataWorks scheduling scenarios after it is successfully created.
A dynamic refresh node for the materialized view is automatically added before the task nodes that have similar computations. When the source table task or an upstream node produces new output, the materialized view is refreshed first to provide the latest data. Downstream nodes then retrieve data from this updated materialized view.
-
Manage materialized views.
You can manage the materialized views created from recommendations within your workspace. This includes checking their hit rates and analyzing or deleting any views that do not perform as expected.
Procedure
Step 1: Enable or disable recommendations
Only a workspace administrator can enable or disable materialized view recommendations.
Go to the Data Asset Governance page.
Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose . On the page that appears, click Go to Data Asset Governance.
-
In the left-side navigation pane, choose .
-
Select a Workspace and click Settings for Materialized View Recommendation. Turn on the intelligent recommendation switch for the project where you want to enable this feature.
A dialog box appears, indicating that recommendations apply only to MaxCompute projects that are already bound to the DataWorks workspace.
Step 2: View recommendations
This module automatically identifies potential materialized views and their associated computing tasks. The relevant owners can then evaluate the recommendations and create the materialized view.
To generate more precise recommendations, the system displays them on the materialized view recommendation page only after the following conditions are met:
-
A scheduled task runs for at least three consecutive days.
-
The input data in a public subquery exceeds 1,000,000 rows.
-
The public subquery contains operators that perform data restructuring, such as JOIN or aggregation (AGG).
-
At the top of the page, select a Workspace and then click the Materialized View Recommendation tab.
-
Adjust the filter criteria, such as Project and Analysis Time Interval, to check for available recommendations.
If recommendations are available within the specified Analysis Time Interval, you can view the following information.
Other filter criteria include Data Source Type, Source Table Name, affected task node, Operation Type, recommendation rating, and operation status. The results table also includes columns for Input Data Volume, compute capacity, Analysis Time, and Number of Materialized Views. In the Actions column, you can click Create Materialized View.
Key parameters:
-
The task identifier in the Materialized View Recommendation column contains a summary of the public subquery. The format is
Aggregate: xx; Inputs: xx, xx;, where:-
Aggregate: Indicates whether the recommended public subquery includes an aggregation operation.
-
Inputs: Lists the names of all source tables used by the public subquery.
-
-
Number of Possibly Affected SQL Statements: The number of other task jobs that use the public subquery.
-
Number of Affected Nodes: The number of scheduling nodes that use the public subquery.
-
Recommendation Rating: Calculated based on the frequency of the subquery, its complexity, and the number of input records.
-
-
Click a task identifier in the Materialized View Recommendation column to view details about the subquery, including Source Table Information, the Public Subquery, and related Job and Scheduling Tasks.
The Source Table Information section includes the table name, table owner, and the node task that produces the table data. The Impact Assessment area is organized into Jobs and Scheduling Tasks tabs. The Jobs tab displays metrics such as Job ID, MaxCompute Project, Workspace, Runtime, CU Consumption, and Compute Capacity. It also provides options to View Code and Execution Details.
Step 3: Create a materialized view
-
Based on your business requirements and the recommendation details, decide whether to create a materialized view on the Materialized View Recommendation page. If so, click Create Materialized View in the Actions column.
-
On the Create Materialized View page, configure the parameters for the materialized view.
-
Configuration - Create Materialized View: Create a materialized view node and generate a materialized view based on the common subquery of the input tasks.
Parameter
Description
Input Table
Automatically detected. No modification is needed.
Create Materialized View
When you create a materialized view for the first time, this is set to Create Materialized View by default.
NoteIf a materialized view with the same input tables already exists, you can select Select Existing Materialized View as needed.
Materialized View Name
Enter a custom name.
lifecycle
Valid values: 1 Day, 7 Days, and Custom Days.
refresh type
The refresh method for the materialized view.
-
Refresh at Fixed Interval
If the source table is an output of a DataWorks task, Time Management Cron Mode is used by default. Otherwise, a fixed interval refresh is used.
-
Time Management Cron Mode
The refresh time defaults to the most recent output time of the upstream source table's generation node.
-
Do Not Refresh
Preview Statement
Preview the SQL statement for the materialized view.
-
-
(Optional) Configuration - Create Materialized View Refresh Node: Create a node that can dynamically refresh the materialized view. When the source table task generates new output, the refresh is triggered to update the materialized view with the latest data.
Configure the Materialized View Refresh Node Name and Node Running Timeout Period. The configuration panel includes the following fields: Input Table, which displays the associated input tables and their output node IDs; Materialized View Refresh Node Name (required), which supports automatically appending a timestamp suffix, for example,
dgc_mv_1716775015179; and Node Running Timeout Period (required), which defaults to 60 minutes. -
(Optional) Configuration - Add Materialized View Refresh Node as Ancestor Node: For nodes with similar computations, add the refresh node as an upstream scheduling dependency to improve the query hit rate for incremental data. In the Add Materialized View Task Dependency area:
This area shows the number of affected task nodes in the current workspace and other workspaces. You can click View Details to see specific task node information.
The task node details dialog box includes fields such as Task ID, Task Name, Owner, Affected Baselines/Highest Level, Task Type, Schedule Type, and Last Modified Time.
-
-
Click Create and Execute. DataWorks starts to create the materialized view. You can monitor the creation status in the Status column on the Materialized View Recommendation page or click View Details in the Actions column to see detailed progress.
-
The Status can be one of the following:
-
To Be Created: The creation of the materialized view has not been initiated through DataWorks.
-
Created: The materialized view was created successfully.
-
Creating: The creation process has been initiated in DataWorks but is not yet complete.
-
Create Failed: The creation process was initiated in DataWorks but failed.
-
-
Click View Details to display the creation details.
On the creation details page, the Plan Information section shows the workspace, creator, status, and creation time. The Process Details section lists five steps: Start Creation, Create Materialized View, Create Materialized View Refresh Node, Add Materialized View Task Dependency, and Complete Creation. Each step shows Execution Successful, and the overall status is Completed.
-
If you configure the Create Materialized View Refresh Node and Add Materialized View Refresh Node as Ancestor Node options, a new materialized view refresh node is added before the nodes with similar computations in the corresponding task workflow. The owner of this new node is the user who created the materialized view.
Step 4: Manage views
You can manage the materialized views created from recommendations within your workspace. This includes checking their hit rates and analyzing or deleting any views that do not perform as expected.
-
At the top of the page, select a Workspace and then click the Materialized View Management tab.
-
Adjust the filter criteria, such as Project, to view the materialized views that were created from recommendations.
Other filter criteria include Data Source Type, Materialized View Name, Creation Time, and owner. The table also displays metrics such as Calls in Previous Day, Total Time Saved, and total saved CU-hours. A Batch Delete operation is also supported.
ImportantIf your MaxCompute project quota is based on the pay-as-you-go billing method, the following formula applies:
Total saved compute capacity = Input data volume × SQL complexity. Fees for MaxCompute SQL jobs are calculated by using the formula:compute capacity × Unit price. For more information, see MaxCompute computing fees (pay-as-you-go).-
Click a materialized view identifier in the Materialized View column to view its details.
The materialized view details page displays the following information: materialized view name (for example,
dgc_mv_1716775189582), data source type, table description, owner, number of reads, baseline task output, table type, and number of direct downstream nodes. The Basic Information section includes creation time, last update time, lifecycle, logical size, number of data rows, partition information, and output task. The Materialized View Properties section includes a link to view code, last refresh time, default refresh frequency, and associated refresh node. The Materialized View Tasks section provides statistics such as hit count, runtime, saved runtime, compute CUs, saved CUs, and compute capacity, which can be viewed by grouping dimension and time range. -
You can click Delete in the Actions column to delete a materialized view.
-