dbt Slim CI for BigQuery: Stop Paying for Every Pull Request
Your dbt CI job may be rebuilding the whole project on every push. Here is how to set up Slim CI on BigQuery, and the traps that quietly undo it.
dbt Slim CI on BigQuery means each pull request builds and tests only the models you changed, plus everything downstream, and reads unchanged upstream models from production. You need production's manifest.json available in the CI run, a state:modified+ selector, and --defer. Miss any one of the three and your CI job quietly rebuilds the whole project on every push, and BigQuery bills you for it.
Most growth-stage teams set up dbt CI once, watch it go green, and never look at it again. The first sign of trouble is rarely a failed build. It is a line item in the BigQuery invoice, or a CI job that takes 40 minutes so engineers stop waiting for it and merge anyway. This post covers how Slim CI works, why it so often fails to be slim, and how to put a hard cost ceiling around it.
Why Does dbt CI Get So Expensive on BigQuery?
Because BigQuery on-demand bills for bytes read, not for time or for the number of queries. Scanning 1 TiB on on-demand pricing costs $6.25 in US regions, once the monthly free tier is used up. That free tier is the first 1 TiB of queries each month for each billing account, and your production runs and analysts normally use it up before CI starts.
Here is an illustrative calculation, not a client figure. Say a full dbt build in your project scans 2 TiB. That is $12.50 per build. A team opening 15 pull requests a week, each pushed to three times, triggers 45 CI runs. That is about $560 a week, or roughly $2,400 a month, spent on validating code rather than serving a single dashboard. A Slim CI job that touches around 5% of the project scans about 0.1 TiB, or roughly $0.63 per run. The same 45 runs cost about $120 a month.
The arithmetic is simple. The problem is that nobody looks. A pattern we see repeatedly in early-stage companies is cloud costs that triple quarter-on-quarter with no query governance, and CI is the corner of the stack that governance usually forgets. It does not appear in any dashboard, it is not tied to a business user, and the person who set it up left a year ago.
It also matters most where the stakes are highest. When we migrate finance logic out of spreadsheets and into dbt models, the gain is not just fewer manual errors. One such migration cut weekly maintenance time by 30 minutes and removed a whole class of recurring mistakes. A CI step is what keeps that gain, because it sits between an analyst's edit and the numbers the board reads. If CI is too slow or too expensive to trust, people route around it and the spreadsheet habits return through the back door.
📺 Watch: [partial] Get started with dbt using BigQuery (The Data Show, w/ Felipe Hoffa & Yufeng Guo)
How Does dbt Slim CI Work on BigQuery?
Slim CI is a simple idea built from three parts that only work together.
- State. dbt compares the pull request's code against a manifest from the last good production run, so it knows what changed.
- Selection. The state:modified+ selector picks models that changed against the production manifest, plus all their downstream dependents.
- Deferral. The --defer flag tells dbt to resolve ref() to production objects for anything it isn't building.
In practice the CI job looks like this:
dbt build --select state:modified+ --defer --state prod-artifacts --target ci
The prod-artifacts folder holds the manifest.json from your latest successful production run. Your production job uploads it to a storage bucket at the end of every run, and your CI job downloads it at the start. That one habit is the foundation. The --defer flag and state:modified selector are free, open-source features of dbt Core, so you do not need a paid dbt platform to do this.
The deferral part is easy to underrate. Without it, a model in your PR that selects from an unchanged staging model fails because that staging model does not exist in the CI dataset. With it, dbt reads the production table instead. That is why a PR touching one mart can be validated for cents rather than dollars.
There is a second tool that is underused on BigQuery. dbt clone creates zero-copy clones of production objects in the CI location, on warehouses such as Snowflake, BigQuery and Databricks. You clone first, then build only the modified models on top. We treat it as a second step, not a first one. Get the basic selection job trusted, then add cloning.

Why Is Your dbt Slim CI BigQuery Job Still Rebuilding Everything?
This is where the textbook version and the delivered version part ways. These are the failure modes we have actually found when auditing CI setups.
1. The production manifest is stale, missing or from a failed run
If the manifest is days old, models changed by other merged PRs look modified in yours. If it is missing, the job either errors or falls back to building everything. Fix it at the source. Publish the artifact only after a successful production run, overwrite it every time, and make the CI job fail loudly if it cannot fetch it. A CI job that silently falls back to a full build is the most expensive bug in this list.
2. Environment-sensitive code makes every model look changed
If model configs or macros vary by target name or environment variable, the compiled state in CI can differ from the production manifest even when nobody touched the model. Symptom: state:modified+ selects most of the project on a one-line PR. Check it by running dbt ls with the same selector and counting the output on an untouched branch. The answer should be zero. If it is not, you have found your leak.
3. Someone fixed a missing-upstream error with a plus sign in the wrong place
When deferral is not configured, builds fail with missing upstream tables. The tempting fix is to select ancestors as well, with a leading plus. That makes the error disappear by building every model upstream of your change, which on a mature project is most of it. The right fix is deferral, not wider selection.
4. Tests quietly scan the biggest tables you own
Selecting state:modified+ builds and tests every downstream model. A not_null or relationships test on a multi-terabyte fact table is a full scan each time it runs. We cover how to find the worst offenders in our guide dbt Tests BigQuery Cost: Find Tests Scanning Full Tables. In CI, some teams narrow the build to direct dependents only with state:modified+1, which builds the changed models and their direct dependents.
5. The gate does not actually gate
A cheap CI job that cannot fail a merge is just a cheap decoration. If your important tests are configured as warnings, CI goes green on broken data. See dbt Test Severity Warn: Find Tests That Never Fail Builds for how to find them.
How Do You Handle Incremental Models and Sources in CI?
This is the section most Slim CI tutorials skip, and it is where the real money goes.
Incremental models start from nothing in CI
A modified incremental model has no table in the fresh CI dataset, so its first run is a full-history build. If that model is your biggest fact table, one tiny edit triggers a scan of everything. You have two options. The first is to clone production incrementals into CI so the model runs as a normal incremental pass on a small delta. The second is to let the first run happen but limit its input window, which brings us to sources.
Limit what CI reads from raw sources
The simplest high-impact change is a target-aware filter in the staging layer, so CI only reads a few days of data:
{% if target.name == 'ci' %}
where event_date >= date_sub(current_date(), interval 3 day)
{% endif %}
This only works well if the source table is partitioned on that column. Otherwise BigQuery still scans everything and you have added complexity for nothing. The trade-off is that sampled data can make relationship tests fail for the wrong reasons, so write CI-time tests with that in mind. We prefer a three-day window and a handful of well-chosen tests over a full copy of production that nobody can afford to run.
If you are working out where your pipeline is leaking money beyond CI, this is exactly the kind of review we do. Explore how Fintel Analytics approaches this — we work with businesses globally to audit and fix dbt and BigQuery cost problems without slowing down the analysts who depend on them.
Do not leave a graveyard of PR datasets behind
If each PR gets its own dataset, abandoned branches leave tables behind that you pay to store. Drop the dataset when the PR closes, and set a default table expiration on the CI project's datasets as a backstop.
How Do You Put a Hard Cost Ceiling on dbt CI in BigQuery?
Selection logic reduces your average cost. A guardrail caps your worst case. You want both, because the worst case is what turns into an awkward conversation with finance.
Cap bytes per query. The dbt BigQuery adapter supports a maximum_bytes_billed setting on the target. If a query would scan more than the limit, BigQuery rejects it before it runs. For a CI target in profiles.yml it looks like this:
ci:
type: bigquery
method: service-account
project: analytics-ci
dataset: pr_ci
maximum_bytes_billed: 53687091200
That is 50 GiB per query, about $0.30 at list price. A runaway query fails with a clear error instead of producing a bill. Start low, watch what breaks, and raise it deliberately. A failure that tells you a model scans too much is useful information.
Isolate CI in its own project. A separate Google Cloud project for CI gives you a clean line on the invoice and its own quotas. It also stops CI jobs competing with production for capacity if you are on slot reservations. At list rates, third-party FinOps analysis puts the crossover between on-demand and slots at roughly 300 to 500 TiB of monthly processing, so most Series A teams are on on-demand, where a per-query cap is exactly the right control.
Label every CI query. Tagging queries with the PR number and job name lets you see which branch, and which engineer's habit, is generating cost. Without labels, CI spend gets lumped into the same bucket as production and nobody can say what it costs.
Treat the cost like any other product. The same discipline applies to the AI tools we build: every run is costed, there is a kill switch, and a human approves the output. A CI pipeline is a small production system. It deserves the same visibility.

Which dbt CI Pattern Fits Your Stage?
Not every team needs the full setup. Here is the rule of thumb we use when advising founders and heads of data. The thresholds are judgement calls from delivery work, not hard limits.
| Your situation | CI pattern | Why |
|---|---|---|
| Under about 30 models, small tables, bills near zero | Full build in CI plus a maximum_bytes_billed cap | Slim CI adds artifact plumbing you do not need yet |
| 30 to 150 models, tables in the tens of GB to low TB | Slim CI: state:modified+, defer, CI project, 3-day source window | Biggest saving for the least complexity |
| Large incremental fact tables, frequent PRs | Add dbt clone for incrementals and narrow tests to direct dependents | Avoids full-history rebuilds triggered by one-line edits |
| Multiple teams, many concurrent PRs | Per-PR datasets with auto-cleanup, query labels, cost alerts by branch | Cost attribution becomes the problem, not selection |
A useful extra at any stage: run a validation pass that compiles and executes models against empty inputs. Newer dbt versions offer an empty flag for this. It catches syntax and reference errors almost for free before you spend money on real data.
The order of operations matters more than the tooling. Fix the manifest first, then selection, then deferral, then sources, then guardrails. If you do the guardrail last, you will spend a month wondering why your numbers are noisy. If you do it first, you will see the real problems immediately.
Frequently Asked Questions
Q: What is dbt Slim CI?
A: Slim CI is a dbt CI job that builds and tests only the models a pull request modified, plus their downstream dependencies. It relies on a production manifest and deferral so unchanged upstream models are read from production rather than rebuilt.
Q: Does dbt Slim CI work with dbt Core, or do I need dbt Cloud?
A: It works with dbt Core. You need the production manifest.json available in CI, the state:modified+ selector and the --defer flag. Many teams run it from GitHub Actions or Cloud Build with the manifest stored in a storage bucket.
Q: Why does state:modified+ select almost every model?
A: Usually the manifest is stale, or configs and macros that depend on the target or environment variables compile differently in CI than in production. Run dbt ls with the selector on an untouched branch. It should return nothing. If it does not, fix the source of the difference before anything else.
Q: How much does a dbt CI run cost on BigQuery?
A: It depends on bytes scanned. On-demand pricing is $6.25 per TiB in US regions (2026), so a full build scanning 2 TiB costs about $12.50, while a Slim CI run scanning 0.1 TiB costs around $0.63. Note that BigQuery bills a minimum of 10 MB per table referenced, which is negligible here.
Q: How do I stop a CI job from running up a huge BigQuery bill?
A: Set maximum_bytes_billed on the CI target so oversized queries are rejected before they run, run CI in a separate project, and limit raw source reads to a few days of partitioned data. Add query labels so you can attribute spend to individual pull requests.
Conclusion
The challenge most growth-stage teams face with dbt Slim CI on BigQuery is not setting it up. It is knowing whether it is actually slim, and whether the gate still protects the numbers leadership relies on. At Fintel Analytics, we have helped payments, fintech and e-commerce teams audit their dbt projects, move spreadsheet logic into tested SQL models, and put cost controls around BigQuery before the bill became a board topic. If your CI runs are slow, expensive or ignored, that is a fixable problem, and the fix usually pays for itself within a quarter.
![[partial] Get started with dbt using BigQuery (The Data Show, w/ Felipe Hoffa & Yufeng Guo)](https://img.youtube.com/vi/FwUIpRET11k/hqdefault.jpg)