8 min readIntermediate§ dbt

dbt Microbatch: Incremental Models Built by Time Batch

How the dbt microbatch strategy works: event_time, batch_size, lookback, targeted backfills, retrying failed batches, and when it beats a hand-written filter.

By Dinesh ChandraSenior Data and AI Engineer · SnowPro certified
Illustrated overview of dbt Microbatch: Incremental Models Built by Time Batch
Fig. 1 · dbt
  1. 1.Microbatch replaces the hand-written is_incremental() filter with configuration: event_time, batch_size, begin and lookback.
  2. 2.dbt filters every upstream ref or source that declares event_time. Upstream models without it are scanned in full for every batch.
  3. 3.Each batch is an independent query, so you can backfill a date range with --event-time-start and --event-time-end and retry only the failed batches.
  4. 4.On Snowflake, microbatch is implemented with delete+insert, and batches can run in parallel unless the model references {{ this }}.
Table of contents

Most incremental models in dbt share the same twenty lines of boilerplate: an {% if is_incremental() %} block, a subquery against {{ this }} to find the latest loaded timestamp, and a few days of lookback for late data. Every team writes it slightly differently, and every variation has its own bug.

The microbatch incremental strategy, available since dbt v1.9, replaces that block with configuration. You tell dbt which column holds the event time, how big each batch is, and how far back to reprocess. dbt then splits the work into one query per time batch, filters your inputs for you, and tracks which batches succeeded.

This post covers when that model fits, how to set it up on a real pipeline, and the edge cases that decide whether it is safe. If you are new to incremental models in general, read incremental models in production first; microbatch is a structured version of the same contract.

The problem

A classic incremental model looks like this:

{{ config(materialized='incremental', unique_key='event_id') }}

select * from {{ ref('stg_events') }}
{% if is_incremental() %}
where event_occurred_at >= (
  select dateadd('day', -3, max(event_occurred_at)) from {{ this }}
)
{% endif %}

It works until it does not. The filter runs as one query, so a month-long backfill is one enormous statement that either finishes or fails as a whole. If it fails at 90 percent, you start again. The lookback is hard-coded in SQL, so changing it means editing every model. And the logic for “what is new” lives in each model, so ten models give you ten slightly different answers.

The common wrong approach

Teams usually fix the backfill problem with variables: pass a start and end date through --vars, add more Jinja to the filter, and loop over date ranges from the orchestrator. That works, but now you maintain a homemade batching framework. Its retry logic lives in Airflow, its state lives in nobody’s head, and a failed run leaves you guessing which days actually loaded.

The other wrong move is to switch a model to microbatch and change nothing upstream. Microbatch only filters inputs that declare an event time. Without that, each batch reads the full upstream table, and a 365-day backfill reads it 365 times.

The approach that works

Step 1: Declare event_time on the inputs

Start upstream. Every model or source that the microbatch model reads, and that should be filtered by time, needs an event_time config:

# models/staging/_stg_events.yml
models:
  - name: stg_events
    config:
      event_time: event_occurred_at

Sources take the same config:

# models/staging/_sources.yml
sources:
  - name: app
    tables:
      - name: raw_events
        config:
          event_time: event_occurred_at

Leave event_time off small reference tables such as customer or product dimensions. You want those read whole, so the join sees every row.

Step 2: Configure the microbatch model

Now the model itself. Notice there is no is_incremental() block:

-- models/marts/fct_daily_events.sql
{{ config(
    materialized='incremental',
    incremental_strategy='microbatch',
    event_time='event_occurred_at',
    batch_size='day',
    begin='2024-01-01',
    lookback=3,
    full_refresh=false
) }}

select
    e.event_id,
    e.event_occurred_at,
    e.customer_id,
    c.customer_segment,
    e.event_type
from {{ ref('stg_events') }} as e
left join {{ ref('dim_customers') }} as c
    on e.customer_id = c.customer_id

What each setting does, per the docs:

  • event_time is the time column of this model. It is required.
  • batch_size is the grain of each batch: hour, day, month or year. Required.
  • begin is where the first build and any full refresh start. Required.
  • lookback reprocesses that many batches before the latest one to catch late-arriving rows. It defaults to 1.
  • full_refresh: false makes the model ignore --full-refresh, which the docs recommend for microbatch models.

When dbt runs this for October 1, the stg_events ref compiles to a subquery filtered to that day, while dim_customers (no event_time) is read in full.

Step 3: Run it

A normal run processes batches from the last bookmark, minus the lookback, up to now, with one query per batch:

dbt run --select fct_daily_events

The log shows each batch as its own unit of work, which is what makes the next two steps possible.

flowchart LR
  run["dbt run"] --> split["Split into day batches"]
  split --> b1["Batch: Oct 1"]
  split --> b2["Batch: Oct 2"]
  split --> b3["Batch: Oct 3"]
  b2 --> fail["Failed"]
  fail --> retry["dbt retry: Oct 2 only"]

One query per batch means a failure costs one batch, not the whole run.

Step 4: Backfill a specific range

To reprocess history, pass a start and end. Both flags must be used together, and each batch in the range runs as an independent query:

dbt run --select fct_daily_events \
  --event-time-start "2026-09-01" \
  --event-time-end "2026-09-08"

All event_time, begin, --event-time-start and --event-time-end values are treated as UTC. If your business day is in another time zone, convert the event column to UTC upstream rather than shifting the batch boundaries.

Step 5: Retry only what failed

If two batches out of thirty fail, you do not rerun thirty:

dbt retry

dbt retry reprocesses only the failed batches from the previous invocation.

Edge cases and changes

Concurrency. On Snowflake and BigQuery, dbt can run batches in parallel, limited by your thread count. It auto-detects whether that is safe: if the model references {{ this }}, batches run one after another, because each batch would read the table being written. The first and last batches never run in parallel. You can override the detection:

{{ config(
    materialized='incremental',
    incremental_strategy='microbatch',
    event_time='event_occurred_at',
    batch_size='day',
    begin='2024-01-01',
    concurrent_batches=false
) }}

Set it to false for logic that depends on order, such as running totals.

How each warehouse writes a batch. The docs list the operation per adapter. Snowflake and Redshift use delete+insert, BigQuery and Spark use insert_overwrite, Databricks uses replace_where, and Postgres uses merge and requires a unique_key. BigQuery and Spark also need partition_by. dbt reserves the right to change the default operation if a warehouse adds a better one.

Opting out of filtering for one ref. If you need a full read of an upstream model that does declare event_time, render the ref directly:

select * from {{ ref('stg_events').render() }}

The docs advise against this for large models, since it brings back the full scan.

Recent fix in dbt v2. The November 2026 release notes record that after a concurrent microbatch batch fails in dbt v2, the remaining unstarted batches are now canceled instead of continuing. Plan your retries around that.

Testing. Microbatch changes how data is loaded, not what a correct row looks like. Keep the unit tests and key data tests from your testing strategy, and add a uniqueness test on the event key: with delete+insert per batch, a duplicate in the source becomes a duplicate in the target.

Trade-offs

Microbatch fits append-mostly, time-stamped data: events, logs, transactions, sensor readings. Each row belongs to exactly one batch by its event time, and late rows arrive within a known window.

It fits poorly when there is no reliable event time, when a row can change long after it was created (an order whose status changes for months), or when you need fine control over the merge. The docs state the model query must read and return exactly one batch, so logic that needs data across batch boundaries, such as a 30-day rolling window, will not see the other days unless you read them unfiltered.

The cost model also changes. Many small queries replace one large one. That gives you resumability and parallelism, but per-query overhead adds up at hour grain over long histories. Pick the largest batch_size that still keeps a single batch comfortable to rerun.

For data that changes in place, a merge on a unique key, or a snapshot for history, is still the right tool.

Pitfalls

  • Upstream without event_time. Every batch scans the whole input. Add event_time to each filtered parent.
  • No begin date. dbt does not know your earliest data. Set begin or pass --event-time-start for history.
  • Full refresh by accident. Set full_refresh: false and use targeted backfills instead.
  • Local time zones. Batches are UTC. Normalize event times to UTC upstream.
  • Order-dependent logic in parallel. Running totals need concurrent_batches=false.

FAQ

Which dbt versions support microbatch?

The docs list microbatch as available from dbt v1.9 and on the “v1 Latest” release track. If you use a custom microbatch macro, you also need the require_batched_execution_for_custom_microbatch_strategy behavior flag.

Do I still need is_incremental() in a microbatch model?

No. dbt builds the time filter from event_time, batch_size and lookback and applies it to every input that declares event_time. Writing your own filter on top would double-filter the data.

How does lookback differ from a backfill?

Lookback runs automatically on every normal run and reprocesses the last few batches to catch late rows. A backfill is a one-off run over a date range you choose with --event-time-start and --event-time-end. Use lookback for routine lateness and backfills for corrections.

Does microbatch need a unique_key on Snowflake?

The docs list unique_key as required only for dbt-postgres. On Snowflake, each batch is written with delete+insert over the batch window, so the time range defines what gets replaced.

Can I convert an existing incremental model in place?

You can change the config, but plan it as a migration. Add event_time upstream first, set begin to your earliest needed date, and backfill a small range in a development schema to compare results with the old model before switching production.

What this means for your pipelines

Microbatch moves the “what is new” logic out of each model and into configuration that dbt understands. That gives you three things a hand-written filter never did: backfills that are just a date range, retries that rerun only failed batches, and safe parallelism on Snowflake and BigQuery.

The work is upstream. Declare event_time on the staging models and sources that carry event data, leave it off small dimensions, and convert the large event models first. Keep merge-based models for data that changes in place. Done that way, your largest incremental models become the easiest ones to repair.

Sources: About microbatch incremental models, Parallel microbatch execution, dbt release notes.

Share this post:X / TwitterLinkedInRedditWhatsApp
D

Dinesh Chandra

Senior Data & AI Engineer · SnowPro Core & Gen AI Certified

4+ years building production data platforms on Snowflake, Databricks, AWS, and Azure. I write from hands-on experience with Medallion architectures, dbt, Airflow, PySpark, and Snowflake Cortex AI. Every tutorial on this blog reflects real pipeline decisions, not documentation rewrites.

Read more about the author →
RE

Related entries

§ dbtIntermediate
Illustrated overview of dbt Model Contracts and Versions for Shared Models

· 9 min

dbt Model Contracts and Versions for Shared Models

Use dbt model contracts, versions, access levels and deprecation dates to change a widely used model without breaking the dashboards and teams that use it.

  • #dbt
  • #data-contracts
  • #governance

Search DataLane

↑↓ navigatealt ↑↓ jump group↵ openesc close