# Run only changed models

**URL:** <https://discourse.getdbt.com/t/run-only-changed-models/9451>\
**Category:** Help\
**Created:** [August 7, 2023, 10:40pm UTC](https://discourse.getdbt.com/t/run-only-changed-models/9451 "2023-08-07T22:40:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![htz](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/htz/32/878_2.png) [@htz](https://discourse.getdbt.com/u/htz)\
**Post date:** [August 7, 2023, 10:40pm UTC](https://discourse.getdbt.com/t/run-only-changed-models/9451/1 "2023-08-07T22:40:28Z")

</div>

I’m trying to run `dbt run -s state:modified` but I’m getting the error

```auto
22:38:24 Running with dbt=1.5.1
22:38:28 Found 22 models, 11 tests, 2 snapshots, 0 analyses, 2 macros, 10 operations, 1 seed files, 44 sources, 0 exposures, 0 metrics, 0 groups
22:38:28 Encountered an error:
Runtime Error
  Got a state selector method, but no comparison manifest

```

Let me know if I missed something in the docs about how to resolve this error but I’m not sure how to proceed

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [August 7, 2023, 10:47pm UTC](https://discourse.getdbt.com/t/run-only-changed-models/9451/2 "2023-08-07T22:47:11Z")

</div>

Hello @htz !

The state:modified method needs to compare your current manifest with another manifest

So you have to save the old manifest in a folder and pass the folder’s path to the state flag

```auto
$ dbt run --select model_b --defer --state prod-run-artifacts

```

> **[Methods | dbt Developer Hub](https://docs.getdbt.com/reference/node-selection/methods#the-state-method)**
>
> Selector methods return all resources that share a common property, using the

> The `state` method is used to select nodes by comparing them against a previous version of the same project, which is represented by a [manifest](https://docs.getdbt.com/reference/artifacts/manifest-json). The file path of the comparison manifest _must_ be specified via the `--state` flag or `DBT_STATE` environment variable.

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [August 7, 2023, 11:36pm UTC](https://discourse.getdbt.com/t/run-only-changed-models/9451/3 "2023-08-07T23:36:28Z")

</div>

If you’re using dbt Cloud, it will handle providing the artifacts for deferral, you just have to pick which job/environment you want to defer to.

---

<div class="post-metadata">

**Author:** ![timothy.davis](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/timothy.davis/32/3708_2.png) [@timothy.davis](https://discourse.getdbt.com/u/timothy.davis)\
**Post date:** [February 26, 2024, 8:59pm UTC](https://discourse.getdbt.com/t/run-only-changed-models/9451/4 "2024-02-26T20:59:13Z")

</div>

Hey, @joellabes! Thanks for mentioning the differences with dbt cloud. Can you an provide an example dbt cloud command to accomplishes this? Specifically a command that would be used in a deployment job in the production environment. I’m still unsure if I need to include the --state or --defer flags in the command.

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [February 27, 2024, 10:58pm UTC](https://discourse.getdbt.com/t/run-only-changed-models/9451/5 "2024-02-27T22:58:23Z")

</div>

> [@timothy.davis](#):
>
> I’m still unsure if I need to include the --state or --defer flags in the command.

In dbt Cloud, you don’t need to specify either of these flags, your command can be as simple as `dbt build --select state:modified+`.

Check out [Continuous integration jobs in dbt Cloud | dbt Developer Hub](https://docs.getdbt.com/docs/deploy/ci-jobs#set-up-ci-jobs)

---

<div class="post-metadata">

**Author:** ![niall.magee](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/niall.magee/32/5343_2.png) [@niall.magee](https://discourse.getdbt.com/u/niall.magee)\
**Post date:** [February 19, 2025, 11:06am UTC](https://discourse.getdbt.com/t/run-only-changed-models/9451/6 "2025-02-19T11:06:22Z")

</div>

I tried this in dbt cloud and got the following error. I am trying to run it in staging before deploying to production Any tips? If I select defer to production it works. Is that deploying teh changes to production or checking the production manifest?

Got a state selector method, but no comparison manifest
