Use materialized view analysis to view and manage materialized views in a tenant. On the Materialized View tab, you can view basic information, refresh status, refresh history, and dependencies. Use this information to monitor materialized views, and analyze individual refreshes to diagnose and resolve issues.
Background information
A materialized view (MV) is a database object that stores the result set of a query. Unlike a regular view, which is a virtual table, an MV is a physical table that stores the result set of the query. When you create an MV, the database executes the associated SQL query and stores the result set on disk. This precomputed data reduces the need for real-time computation, thereby improving query performance and simplifying complex query logic. Materialized views are commonly used in scenarios that require fast report generation and data analysis. For more information about materialized views, see Overview of materialized views (MySQL mode) and Overview of materialized views (Oracle mode).
To ensure data consistency between the MV and the base table, the MV must be refreshed periodically. The materialized view analysis feature helps you:
- View the basic information and configurations of an MV.
- Monitor the refresh status and latency of an MV.
- Review the refresh history and the outcome of each refresh.
- Inspect the views involved in a refresh, the duration and execution plan of each SQL step, and the number of rows changed in the base tables. Use these details to diagnose slow or failed refreshes.
- Inspect dependencies between materialized views, base tables, and other materialized views to determine the scope of a refresh issue.
Note
You can use materialized view diagnostics with OceanBase Database versions from V4.4.2.2 (inclusive) to V4.5.0.0 (exclusive), and with V5.0.2.0 or later.
View the list of materialized views
Log in to the OceanBase Cloud console.
In the left-side navigation pane, click Instances.
In the instance list, find the target instance, click the instance name, and go to the Overview page of the instance.
In the left-side navigation pane, click Diagnostics, and then select the Real-Time Diagnostics tab on the Diagnostics page.
In the middle of the page, click the Materialized View tab.
In the upper-left corner of the Materialized View tab, select a tenant.
On the Materialized View tab, click View List to see the materialized views in the selected tenant.
The following table describes the information in the list of materialized views.
Column |
Description |
|---|---|
| ID | The unique identifier of the materialized view. |
| Database | The database that contains the materialized view. |
| Name | The name of the materialized view. Click the name to open its refresh status panel. For details, see View materialized view details. |
| Build mode | How the materialized view is initially populated. • IMMEDIATE runs the query and populates the view when you create it. • DEFERRED leaves the view unpopulated when you create it. You must trigger the build manually. |
| Refresh statistics | The type of refresh statistics collected. • TYPICAL collects typical refresh statistics. • ADVANCED collects advanced refresh statistics. |
| Refresh Mode | When the materialized view refreshes. • ON COMMIT refreshes the view automatically when changes to a base table are committed. • ON DEMAND refreshes the view manually or on a schedule. • ON STATEMENT refreshes the view each time the relevant statement runs. |
| Refresh method | How the materialized view refreshes. • COMPLETE performs a full refresh. It reruns the query and replaces the existing data. • FAST performs an incremental refresh. It updates only the changed data and requires a materialized view log (Mlog). |
| Refresh interval | The configured interval between automatic refreshes. |
| Current delay (seconds) | The time elapsed since the last refresh, in seconds. A long delay can indicate that the data in the materialized view is stale. |
| Next Refresh | The next scheduled refresh time. |
| Last Refresh Time | The time of the most recent refresh. |
| Last Refresh Time (seconds) | How long the most recent refresh took, in seconds. |
Note
- Filter the list by database, name, build mode, refresh mode, or refresh method. To reload the list, click the refresh button to the right of the filters.
- To see the view definition, click the materialized view name and check the refresh status panel.
- If the current delay is high, check whether the refresh task is running normally or consider adjusting the refresh interval.
- Use the last refresh duration to assess refresh performance. If a refresh takes too long, consider optimizing the view definition or refresh method.
View materialized view details
The refresh status panel shows the basic details, refresh records, and dependencies of a materialized view.
On the View List tab, click the materialized view name to open the Materialized View Refresh Status panel.
Review the Basic details section at the top of the panel.
FieldDescriptionView name The name of the materialized view. Database The database that contains the materialized view. Current status The current status of the materialized view.
• Running indicates that a refresh is in progress.
• Delay indicates that the scheduled refresh time has passed and the refresh has yet to start.
• Normal applies in all other cases.Degree of parallelism The degree of parallelism used to refresh the materialized view. Last refresh time The start time of the most recent refresh. Next refresh time The scheduled start time of the next refresh. View definition Click View to show the view definition statement or Collapse to hide it. On the Refresh Record tab, review the refresh activity for this materialized view. The panel opens on this tab by default.
SectionDescriptionRefresh state heat map Each row shows one day of refresh activity. Colors on the timeline indicate Success, Initialization, Failed, or No data. Hover over a cell that contains a refresh record to see its time and result. Drag the slider below the heat map to zoom in on a time window within the day. Refresh Record Lists refresh records for the materialized view, including Start Time, Refresh method, Time taken (seconds), and Results. Use Refresh method (incremental or full refresh) and Results (success, initialization, or failure) to filter the records. To analyze a refresh, click Analysis in the Operation column. Click the Dependency tab to inspect the dependency graph and determine whether a refresh issue could affect other materialized views.
The graph shows dependencies from top to bottom. Materialized views that depend on other objects appear toward the top, and the base tables they depend on appear toward the bottom. Arrows point from each view to the objects it depends on. A highlighted border identifies the current materialized view. Hover over a card to highlight its direct connections.
Card typeInformation shownMaterialized view The materialized view name, Database, and Refresh method. Base table The base table name, Database, and Relationship. If the materialized view has no dependency data, the tab displays No dependency data available.
View refresh records
Use refresh records to track refreshes across all materialized views in the current tenant, identify trends in refresh frequency and performance, and spot refresh issues.
On the Materialized View tab, click Refresh Record.
Use the following filters to find the records you need.
- The time range defaults to the last hour. You can select the last 5 minutes, 30 minutes, 1 hour, 6 hours, or 1 day. You can also specify a custom range.
- Use Database to filter by the database that contains the materialized view.
- Use Name to filter by materialized view name.
- Use Refresh Type to filter by the refresh method used.
- Use Refresh results to filter for success, initialization, or failure.
To reload the refresh records, click the refresh button to the right of the filters.
Review the refresh records in the list.
Column |
Description |
|---|---|
| ID | The unique identifier of the refresh record. Click the ID to open the refresh analysis page. For details, see Analyze a single refresh. |
| Database | The database that contains the materialized view. |
| Name | The name of the materialized view. |
| Refresh Type | The method used for the refresh, such as full or incremental refresh. |
| Refresh time (seconds) | How long the refresh took, in seconds. You can sort by this column. |
| Start Time | The time the refresh started. The list sorts by this column in descending order by default. |
| End Time | The time the refresh ended. You can sort by this column. |
| Result | The console displays Success when the refresh succeeds and Initialization while it is initializing. In other cases, it displays the result returned by the API. |
Note
- If a refresh takes a long time, click its ID to review the time spent in each step and the execution plans. You can also check the complexity of the view definition and the amount of data in the base tables to see whether optimizing the refresh method or adjusting the refresh strategy would help.
- If a refresh fails, click its ID to see which views failed to refresh and which steps ran. Check the base table data and materialized view logs (Mlogs) for issues.
- Use the pagination controls at the bottom of the list to switch pages or change the number of records per page.
Analyze a single refresh
The refresh analysis page shows which materialized views were involved in a refresh, how long each SQL step took, its execution plan, and how many rows changed in the base tables. Use this information to pinpoint the step that slowed or failed.
Open the refresh analysis page in either of the following ways.
- In the tenant-wide Refresh Record list, click the ID of the refresh record.
- On the Refresh Record tab of the refresh status panel, click Analysis in the Operation column for the record.
Both options open the same page in a new browser tab. The page title shows the Refresh record ID. Click the back button to the left of the title to return to the Refresh Record tab.
In the Overview section, review the summary for this refresh.
FieldDescriptionRefresh results The console displays Success when the refresh succeeds and Initialization while it is initializing. In other cases, it displays the result returned by the API. Number of views refreshed The number of materialized views involved in this refresh. A refresh can involve one or more views. Refresh duration The elapsed time from submission of the refresh task until the last materialized view finishes refreshing. Scheduling delay The total time during the refresh when no view is being refreshed. Database The database that contains the materialized view. Refresh method The method used for this refresh. Degree of parallelism The degree of parallelism used for this refresh. Trace ID The trace ID of this refresh. Use it to investigate further in the database. Target SCN The target SCN of this refresh. Start time The time this refresh started. End time The time this refresh ended. In the Refresh details section, review each materialized view involved in the refresh.
ColumnDescriptionView name The materialized view name in the format database_name.materialized_view_name.Role The role of the view in this refresh.
•ROOTidentifies the primary materialized view for this refresh.
•CHILDidentifies another materialized view refreshed along with the primary view during a nested refresh.Refresh method The method used to refresh this view. Execution node The node that refreshed this view. Start and end time The start and end times of this view's refresh. Elapsed time How long this view took to refresh. The bar shows this view's share of the total refresh duration. Scheduling delay The elapsed time between the start of the overall refresh and the start of this view's refresh. Result The result returned by the database for this view, such as OK.Click the expand button to the left of a materialized view's row to see how it was refreshed.
SectionDescriptionSQL execution time by step Lists the SQL steps in execution order and shows Steps, SQLID, SQL, Elapsed time, Proportion, and Execution plan. Use this list to find the step that took the longest. If the view failed to refresh, the list shows only the steps that ran before the failure. Base table Shows how many rows changed in each base table involved in this refresh. The columns are Base table (in the format database_name.table_name), Total number of rows, Number of rows deleted, Number of rows inserted, and Number of rows updated.(Optional) Under SQL execution time by step, click the plan ID in the Execution plan column for a step. The Execution Plan Details panel opens and shows the SQL execution plan for that step.
- The Operator table shows operators in a tree. It includes Operator, Object name, Estimated number of rows, Estimated time (µs), Actual number of rows, Actual time taken (µs), I/O time (µs), CPU time (µs), Degree of parallelism, Row count skew, Execution time skew, Number of starts, Maximum memory usage, and Execution server. Compare estimated and actual row counts and durations to assess the execution plan.
- Operator details shows the full execution plan output as text.
(Optional) Click Download report in the upper-right corner to download a text report that you can share or attach to a support ticket. The file name follows the format
refresh-<refresh_record_id>.txt. If there is no report, the page displays No reports yet.
Note
If the page displays No detailed data was found for this refresh record., the database has no statistics for this refresh.
Common troubleshooting scenarios
Slow refresh
In the tenant-wide Refresh Record list, select a time range and filter by database and name. Sort by Refresh time (seconds) in descending order to find slow refreshes.
Click the record ID to open the refresh analysis page.
In the overview, compare the refresh duration with the scheduling delay to determine whether most of the time was spent waiting to run or performing the refresh.
In the refresh details, find the materialized view that took the longest to refresh and expand its row. Find the SQL step that accounts for the largest share of the execution time, open its execution plan, and identify the operator with the longest actual execution time. Check the base table section for unusually high counts of inserted, updated, or deleted rows.
Use this information to decide whether to connect to the database for further investigation. For example, consider tuning the SQL for the slowest step or adjusting the refresh method and interval.
Failed refresh
In the tenant-wide Refresh Record list, set Refresh results to Failure to find failed refreshes. You can also check the heat map in the refresh status panel to see when failures occurred.
Click a record ID to open the refresh analysis page. In the refresh details, find the materialized view that failed to refresh and expand its row to see the steps that ran before the failure.
On the View List tab, click the name of the materialized view. In the refresh status panel, click the Dependency tab to find other materialized views that depend on it. Determine whether the failure might affect the accuracy of their data and whether to check those views as well.