Warehouse-specific optimizations help your data models run faster and use resources better by using features unique to your data warehouse.
Warehouse-specific optimizations in dbt
config( materialized='table', unique_key='id', incremental_strategy='merge', cluster_by=['column_name'], dist='key_column' )
Use config() in your dbt model files to set warehouse-specific options.
Options vary by warehouse, like clustering in Snowflake or distribution in Redshift.
config( materialized='incremental', unique_key='user_id', incremental_strategy='merge' )
config( materialized='table', dist='user_id', sort='created_at' )
config( materialized='incremental', cluster_by=['region', 'date'] )
This dbt model uses warehouse-specific optimization by setting incremental materialization with merge strategy and clustering by customer_id. It only processes new or changed orders to save time and resources.
-- dbt model: orders.sql
{{ config(
materialized='incremental',
unique_key='order_id',
incremental_strategy='merge',
cluster_by=['customer_id']
) }}
select
order_id,
customer_id,
order_date,
total_amount
from raw.orders
where order_date > (select max(order_date) from {{ this }}) or not exists (select 1 from {{ this }})Always check your warehouse documentation for supported optimization options.
Test optimizations on small data first to see their effect before applying to large datasets.
Combining multiple optimizations can improve performance but also add complexity.
Warehouse-specific optimizations make your dbt models faster and cheaper by using special features of your data warehouse.
Use config() in dbt models to apply these optimizations.
Examples include clustering, distribution keys, incremental loading, and merge strategies.