# dbt model freezes on \`dbt run\`

**URL:** <https://discourse.getdbt.com/t/dbt-model-freezes-on-dbt-run/5389>\
**Category:** Help\
**Tags:** postgres\
**Created:** [November 21, 2022, 8:35am UTC](https://discourse.getdbt.com/t/dbt-model-freezes-on-dbt-run/5389 "2022-11-21T08:35:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![linards](https://avatars.discourse-cdn.com/v4/letter/l/5fc32e/32.png) [@linards](https://discourse.getdbt.com/u/linards)\
**Post date:** [November 21, 2022, 8:35am UTC](https://discourse.getdbt.com/t/dbt-model-freezes-on-dbt-run/5389/1 "2022-11-21T08:35:57Z")

</div>

I’m working on a dbt project with Postgres database, currently there are ~40 models there and they all run fine if I select them with `--models` selector, however when I try to run all models with `dbt run` one of the models (relatively large/complex in the context of the project - a few millions of rows, generates in ~5 mins) gets stuck and does not finishes. Oddly enough I can observe Postgres reporting 3 identical `CREATE TABLE` queries being executed, however no locks are reported by Postgres.

---

<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:** [November 25, 2022, 2:39am UTC](https://discourse.getdbt.com/t/dbt-model-freezes-on-dbt-run/5389/2 "2022-11-25T02:39:09Z")

</div>

How many threads are you using? (See [understanding threads](https://docs.getdbt.com/docs/get-started/connection-profiles#understanding-threads) for background)

Do you see the same issue if you try doing `dbt run --threads 1`? If you’re currently using many threads (say, 8) and it works with a single thread, you could try changing down the number of threads to trade off parallelisation and reliability.

---

<div class="post-metadata">

**Author:** ![linards](https://avatars.discourse-cdn.com/v4/letter/l/5fc32e/32.png) [@linards](https://discourse.getdbt.com/u/linards)\
**Post date:** [November 30, 2022, 11:56am UTC](https://discourse.getdbt.com/t/dbt-model-freezes-on-dbt-run/5389/3 "2022-11-30T11:56:47Z")

</div>

Thanks, seems to solve the issue, I was running DBT with 2 threads, as Postgres instance has 2 vCPUs, but something was obviously deadlocking after all.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [December 7, 2022, 11:57am UTC](https://discourse.getdbt.com/t/dbt-model-freezes-on-dbt-run/5389/4 "2022-12-07T11:57:24Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
