Select materialized view

更新时间:
复制 MD 格式

Check the status of a materialized view to detect changes in its source table and ensure that the view is valid.

Background

A materialized view can be in one of the following two states:

  • Valid

    When you run a query, MaxCompute reads data directly from the materialized view instead of the source table.

  • Invalid

    When you run a query, MaxCompute cannot read data directly from the materialized view. It reads data from the source table instead, which prevents query acceleration.

Query materialized view status

Use the following function to check whether the data in a materialized view is valid.

  • Syntax

    Boolean materialized_view_is_valid(<mv_name>,<partition>);
  • Examples

    This function returns true if the data in mf_mv_refresh4 is consistent with the latest data in the source table; otherwise, it returns false.

    • SELECT materialized_view_is_valid("mf_mv_refresh4");
    • --Specify partition values.
      SELECT materialized_view_is_valid("mf_mv_refresh_pts","20220810","beijing");
      
      --Specify level-2 partition values.
      SELECT materialized_view_is_valid("mf_mv_refresh_pts_part","20220810","beijing");

Related commands