CREATE MATERIALIZED VIEW statement to create s. To learn more, see the
how-to guides.
The syntax is:
<select_query> is of the form:
WITH DATA. This means that when the
view is created, it refreshes using all the current data in the underlying
or . This occurs once when the view is created.
If you want the view to be refreshed regularly, you can use a refresh policy. If
you do not want the view to update when it is first created, use the
WITH NO DATA parameter. For more information, see
refresh_continuous_aggregate.
s have some limitations of what types of queries they can
support. For more information, see the
s section.
In v2.17.0 and greater (with 15+), you can dramatically decrease the amount
of data written on a in the presence of a small number of changes,
reduce the I/O cost of refreshing a , and generate fewer Write-Ahead
Logs (WAL) by enabling the timescaledb.enable_merge_on_cagg_refresh
GUC parameter. This enables
refresh to use MERGE instead of deleting old materialized data and re-inserting.
This parameter only works for finalized s
that don’t have compression enabled. It is disabled by default.
To enable this parameter for your session:
Samples
Create a daily view:Arguments
WITH clause options:
Returns
For standardCREATE MATERIALIZED VIEW return behavior, see the PostgreSQL CREATE MATERIALIZED VIEW documentation.
For more information, see the real-time aggregates section.