Skip to main content

Materialize configurations

Performance optimizations

Clusters

Enable the configuration of clusters.

The default cluster that is used to maintain materialized views or indexes can be configured in your profile using the cluster connection parameter. To override the cluster that is used for specific models (or groups of models), use the cluster configuration parameter.

my_view_cluster.sql
{{ config(materialized='materializedview', cluster='not_default') }}

select ...
dbt_project.yml
models:
project_name:
+materialized: materializedview
+cluster: not_default

Incremental models: Materialized Views

Materialize, at its core, is a real-time database that delivers incremental view updates without ever compromising on latency or correctness. Use materialized views to compute and incrementally update the results of your query.

Indexes

Enable additional configuration for indexes.

Like in any standard relational database, you can use indexes to optimize query performance in Materialize. Improvements can be significant, reducing response times down to single-digit milliseconds.

Materialized views (materializedview), views (view) and sources (source) may have a list of indexes defined. Each Materialize index can have the following components:

  • columns (list, required): one or more columns on which the index is defined. To create an index that uses all columns, use the default component instead.
  • name (string, optional): the name for the index. If unspecified, Materialize will use the materialization name and column names provided.
  • cluster (string, optional): the cluster to use to create the index. If unspecified, indexes will be created in the cluster used to create the materialization.
  • default (bool, optional): Default: False. If set to True, creates a default index that uses all columns.
my_view_index.sql
{{ config(materialized='view',
indexes=[{'columns': ['col_a'], 'cluster': 'cluster_a'}]) }}
indexes=[{'columns': ['symbol']}]) }}

select ...
my_view_default_index.sql
{{ config(materialized='view',
indexes=[{'default': True}]) }}

select ...

Tests

If you set the optional --store-failures flag or store_failures config, dbt will create a materialized view for each configured test that can keep track of failures over time. By default, test views are created in a schema suffixed with dbt_test__audit. To specify a custom suffix, use the schema config.

dbt_project.yml
tests:
project_name:
+store_failures: true
+schema: test
0