Incremental strategies help update data efficiently by adding or changing only new or changed parts instead of reloading everything.
Incremental strategies (append, merge, delete+insert) in dbt
incremental_strategy: append | merge | delete+insert
append adds only new rows to the existing table.
merge updates existing rows and inserts new rows based on a key.
delete+insert deletes matching rows and inserts fresh data.
incremental_strategy: append
id matches and inserts new rows if id is new.incremental_strategy: merge unique_key: id
id in the new data, then inserts all new rows.incremental_strategy: delete+insert unique_key: id
This dbt model uses the merge strategy to update existing customers and add new ones based on customer_id. It selects only customers updated after the last run.
version: 2 models: - name: customers_incremental config: materialized: incremental incremental_strategy: merge unique_key: customer_id -- SQL to update or insert customers select customer_id, customer_name, updated_at from source.customers where updated_at > (select coalesce(max(updated_at), '1900-01-01') from {{ this }})
Use append when you only add new data and never update old rows.
merge requires a unique key to match rows for update or insert.
delete+insert can be slower but is useful when updates are complex.
Incremental strategies help update data efficiently without full reloads.
append adds new rows, merge updates and adds rows, delete+insert replaces matching rows.
Choose the strategy based on your data update needs and performance.