Materialized views#
Starburst Enterprise platform (SEP) supports materialized views with the Hive and Iceberg connectors.
Materialized views increase query performance by providing pre-computed results from complex, analytical queries. With SEP, you can run federated queries, create materialized views, and access catalogs of results through the Hive and Iceberg connectors.
Materialized views created in a Hive catalog may be automatically refreshed, as discussed in this document. For more information about Iceberg automatic refresh, see the Iceberg automatic refresh section.
Prerequisites#
Your SEP platform administrator or a data engineer with administrative access to SEP has to first enable materialized views in one or more Hive or Iceberg catalogs. Check with them to learn which catalogs are enabled, and which schemas may be used.
You also must have the necessary access privileges to create data in the schema designated in each enabled catalog.
Create and use a materialized view#
Any federated query that runs successfully in SEP can be used to
create a materialized view. Materialized views in SEP are
created in the same way as in other data platforms, with a CREATE MATERIALIZED VIEW statement. In the following
example, the mysalescatalog has been configured to allow materialized views:
CREATE MATERIALIZED VIEW mysalescatalog.mysalesschema.mv_cust_tot_return AS
SELECT
sr_customer_sk ctr_customer_sk,
sr_store_sk ctr_store_sk,
sum(sr_return_amt) ctr_total_return
FROM
tpcds.sf1.store_returns,
tpcds.sf1.date_dim
WHERE ( (sr_returned_date_sk = d_date_sk) AND (d_year > 2000) )
GROUP BY sr_customer_sk, sr_store_sk
;
Once a materialized view exists, you can query it like any regular table:
SELECT * FROM mycatalog.mysalesschema.mv_cust_tot_return;
When querying fresh materialized views within their grace period, access control
checks on source tables are skipped by default. However, if the materialized
view is configured with run_as_invoker=true and the
materialized-views.allow-run-as-invoker property is enabled, queries execute
as the invoking user and perform standard access control checks on source
tables.
Automatically refresh materialized views in Hive#
Hive catalogs in SEP configured to allow materialized views
provide several WITH clause properties to configure refresh schedules and how
new data is imported:
refresh_intervalandcron: Choose one method to specify a refresh frequency. The defined interval must be greater than or equal to five minutes.max_import_duration: Specifies how long to allow a refresh to complete before failing. Defaults to120m.grace_period: Specifies the amount of time in-flight queries can run against an expiring snapshot.incremental_column: Specifies the column to be used to identify new data since the last refresh. If you do not use this field, SEP performs a full refresh.failed_refresh_limit: Specifies the maximum number of consecutive refresh failures allowed before refresh operations are temporarily disabled. By default, there is no set limit for consecutive refresh failures. The counter resets after a successful refresh, a change to the refresh limit value, or when the refresh is re-enabled at the next scheduled refresh time.
We suggest that you review the Hive connector documentation , which has more information about these properties.
In the following example, the refresh_interval property is used to
automatically refresh the data every 24 hours from the time the CREATE
statement initially runs:
CREATE MATERIALIZED VIEW myhive.mysalesschema.mv_cust_tot_return
WITH (
refresh_interval = '24h',
grace_period = '5m',
max_import_duration = '30m',
failed_refresh_limit = '2'
) AS
SELECT
sr_customer_sk ctr_customer_sk,
sr_store_sk ctr_store_sk,
sum(sr_return_amt) ctr_total_return
FROM
tpcds.sf1.store_returns,
tpcds.sf1.date_dim
WHERE ( (sr_returned_date_sk = d_date_sk) AND (d_year > 2000) )
GROUP BY sr_customer_sk, sr_store_sk
;
In this example, the refresh runs for a maximum of 30 minutes. Unless the cron
property is specified, the time at which data in a materialized view is
refreshed is based on the moment the CREATE MATERIALIZED VIEW statement first
runs, plus the refresh_interval. In addition, the refresh has a
failed_refresh_limit set to 2. If the refresh fails two times, it is
temporarily disabled.
You can run refreshes on a set schedule by using the cron property instead.
The cron property uses normal cron expressions. Here is the same materialized
view, created with a cron schedule and an incremental column:
CREATE MATERIALIZED VIEW myhive.mysalesschema.mv_cust_tot_return
WITH (
cron = '30 2 * * *'
grace_period = '5m',
max_import_duration = '30m',
incremental_column = 'sr_returned_date_sk'
) AS
SELECT
sr_customer_sk ctr_customer_sk,
sr_store_sk ctr_store_sk,
sum(sr_return_amt) ctr_total_return
FROM
tpcds.sf1.store_returns,
tpcds.sf1.date_dim
WHERE ( (sr_returned_date_sk = d_date_sk) AND (d_year > 2000) )
GROUP BY sr_customer_sk, sr_store_sk
;
This causes the refresh to execute at 2:30 AM daily, and loads only new data as
determined by the sr_returned_date_sk date column.
Enable Iceberg materialized views#
Built-in access control (BIAC) must be configured to own table entities in order to enable materialized views in an Iceberg catalog.
See Using BIAC with Iceberg materialized views for more details.
Iceberg incremental column refresh#
Iceberg materialized views support a predicate-based incremental refresh using
the incremental_column property. On each refresh, only rows whose column value
exceeds the current maximum in the storage table are appended, rather than
replacing all data.
This is distinct from the Hive incremental_column property, which works with
a scheduler. Iceberg incremental refresh is triggered manually with
REFRESH MATERIALIZED VIEW and requires
enabling iceberg.materialized-view-incremental-column-refresh.enabled=true in
the catalog configuration.
Iceberg materialized views can still be refreshed on a schedule independently of
incremental_column, using the refresh_schedule property. See Automatic
refresh.
See Incremental column refresh in the Iceberg connector documentation for configuration details, supported column types, and query restrictions.
Automatic materialized view substitution#
Note
Automatic materialized view substitution is a public preview feature.
Automatic materialized view substitution is a query-time acceleration feature that uses pre-computed materialized views to execute part or all of a query, without requiring the query to reference the materialized view directly. When a query reads from base tables that are also covered by an eligible materialized view, SEP identifies the materialized view and substitutes it into the query plan, avoiding the need to scan the base tables and repeat the computation at query time.
Materialized views in Iceberg and Hive catalogs can be eligible for substitution. The source tables of a materialized view eligible for substitution can use the following connectors:
Delta Lake, including through Great Lakes and Starburst Warp Speed
Hudi, including through Great Lakes
Teradata, including Teradata Direct
The teradata_direct_legacy connector doesn’t support automatic materialized
view substitution.
The materialization is always stored in the same type of catalog as the materialized view, regardless of the source of the data:
Materialized views in an Iceberg catalog are stored as Iceberg tables.
Materialized views in a Hive catalog are stored as Hive tables, which the cache service creates and refreshes.
A materialized view is only considered for substitution while its content is not stale, based on the grace period configured for the view.
Users need SELECT privileges on the materialized view, including the columns
the query reads, for it to be substituted into their queries. If a user does not
have access, the query reads from the base tables instead.
The row filters and column masks of the user who runs the query still apply when SEP substitutes a materialized view. If the user who refreshes the materialized view has a row filter or column mask, the refresh records it. Only queries with the same row filter or column mask can then use the materialized view.
Supported queries#
The definition of a materialized view eligible for automatic substitution can contain table scans, filters, projections, and aggregations. SEP substitutes the materialized view when the query matches its definition.
Filters#
The WHERE clause of the query must apply the same predicate to the same table
as the definition. SEP doesn’t check whether one predicate covers another,
so a query with an additional AND condition or a narrower condition than the
definition isn’t substituted.
If the definition of the materialized view has no filter, the query can still have one. SEP reads from the materialized view and applies the filter of the query to the result.
Projections#
Each expression in the SELECT list of the query must match an expression that
the materialized view computes, in any order, or be computed from columns that
the materialized view stores unchanged from the source table. The materialized
view can compute expressions that the query doesn’t use.
Aggregations#
The materialized view must group by the same keys over the same source as the
query, and compute at least the aggregates of the query. DISTINCT,
FILTER (WHERE ...), and ORDER BY in each aggregate must match the
materialized view. SEP doesn’t roll up a materialized view with a finer
grouping to answer a query with a coarser grouping.
Supported expressions#
Filters, projections, and aggregate arguments, in both the definition and the
query, can only use the following expressions. A query can also use other
expressions in its SELECT list if SEP can compute them from the columns
of the materialized view. See Projections.
Category |
Supported expressions |
|---|---|
Comparison |
|
Logical |
|
Predicates |
|
Arithmetic |
|
Functions |
|
Casts |
|
Row fields |
Field access on a |
Constants |
Values of type |
Other expressions, such as CASE, COALESCE, LIKE, lambda expressions, and
ARRAY or ROW constructors, aren’t supported.
Supported aggregate functions#
Aggregations can only use the following aggregate functions:
count()sum()avg()min()max()array_agg()
Each argument of an aggregate function must be a column or a supported
expression. GROUPING SETS, ROLLUP, and CUBE aren’t supported.
Requirements#
Automatic materialized view substitution requires the following:
Starburst Control Plane is installed and accessible. Control Plane hosts the materialization metastore used to track materialized views eligible for substitution.
The Starburst Control Plane and SEP cluster versions match.
Substitution for materialized views in a Hive catalog also requires the following:
The cache service is deployed.
The Hive catalog is configured to allow materialized views.
Configuration#
Automatic materialized view substitution requires the materialization
metastore, which Starburst Control Plane enables by default with the
materialization.metastore.enabled property.
The coordinator uses the following properties to control automatic materialized view substitution. When the coordinator is configured to use Starburst Control Plane, all of these properties are enabled by default:
Property name |
Description |
Default value |
|---|---|---|
|
Allows a materialized view to be marked as eligible for substitution with
the |
|
|
Enables substitution on the query side. |
|
|
Makes |
|
Each materialized view must also be enabled individually. A materialized view is
only considered for substitution when its substitution_enabled property is set
to true. The property is only available when the
materialized-view-substitution.support.enabled coordinator property is true.
Set the property when you create the materialized view:
CREATE MATERIALIZED VIEW mycatalog.myschema.mv_orders
WITH (substitution_enabled = true) AS
SELECT orderkey, custkey, orderstatus, totalprice
FROM postgresql.public.orders;
To enable or disable substitution for an existing materialized view, use ALTER MATERIALIZED VIEW:
ALTER MATERIALIZED VIEW mycatalog.myschema.mv_orders
SET PROPERTIES substitution_enabled = false;
Note
Every refresh records the data that it writes, even if substitution is disabled
for the materialized view. The substitution_enabled property only turns that
record on or off. As a result:
Setting
substitution_enabledtotruetakes effect immediately. If no refresh of the materialized view has been recorded yet, it takes effect after the next REFRESH MATERIALIZED VIEW.If a cluster without substitution support refreshes the materialized view, it can’t be used for substitution until a cluster with substitution support runs a full refresh of it.
Use SHOW CREATE MATERIALIZED VIEW to check the current value. For
materialized views in a Hive catalog, setting substitution_enabled to false
removes the property, so it does not appear in the SHOW CREATE MATERIALIZED VIEW output.
Automatic materialized view substitution can be disabled for an individual
session using the materialized_view_substitution_enabled session property:
SET SESSION materialized_view_substitution_enabled = false;
Monitoring#
EXPLAIN#
EXPLAIN and EXPLAIN ANALYZE show a Substituted materialized views: block. It lists each materialized view that the query uses, its last
refresh time, and the plan that it replaced:
Substituted materialized views:
iceberg.sales.daily_totals (refreshed 2026-08-23T10:00:00Z)
replaced plan:
TableScan[table = hive.sales.orders]
Event listeners#
The QueryCompletedEvent of event listeners
includes the statistics.materializedViewSubstitutions field. It holds one
entry for each materialized view that SEP considered for substitution, with
the fields materializedView, outcome, storageTable, lastRefreshTime,
and replacedPlanText.
The outcome field has one of the following values:
Group |
Outcomes |
|---|---|
Used |
|
Query or materialized view definition |
|
Freshness |
|
Storage table |
|
Permissions |
|
Metrics#
SEP exports the following metrics over JMX and on the
/metrics endpoint:
io.starburst.server.substitution:name=MvSubstitutionStatshas one counter for each outcome, named after the outcome, such asSubstituted,ScanNotSubstitutable, andStale. The counts include planning forEXPLAIN, not only queries that run.io.starburst.server.substitution:name=MaterializationIndexhasSkippedCount, the number of materialized views that SEP skipped because it couldn’t read their stored definition.
SEP also exports the OpenTelemetry counter
mv_substitution_attempts, with an outcome attribute.
Limitations#
The following operations are not currently eligible for automatic materialized view substitution:
Expressions that aren’t listed in Supported expressions
Aggregate functions that aren’t listed in Supported aggregate functions, and
GROUPING SETS,ROLLUP, andCUBE