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.
{{ config(materialized='materializedview', cluster='not_default') }}
select ...
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 thedefault
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 toTrue
, creates a default index that uses all columns.
{{ config(materialized='view',
indexes=[{'columns': ['col_a'], 'cluster': 'cluster_a'}]) }}
indexes=[{'columns': ['symbol']}]) }}
select ...
{{ 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.
tests:
project_name:
+store_failures: true
+schema: test