# dbt compile: order of queries to run

**URL:** <https://discourse.getdbt.com/t/dbt-compile-order-of-queries-to-run/17310>\
**Category:** Help\
**Created:** [December 11, 2024, 9:38am UTC](https://discourse.getdbt.com/t/dbt-compile-order-of-queries-to-run/17310 "2024-12-11T09:38:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavideA](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DavideA](https://discourse.getdbt.com/u/DavideA)\
**Post date:** [December 11, 2024, 9:38am UTC](https://discourse.getdbt.com/t/dbt-compile-order-of-queries-to-run/17310/1 "2024-12-11T09:38:04Z")

</div>

Dear dbt users.

I am using dbt for some ELT work. I was wondering if it is possible to, after using dbt compile to generate the SQL queries, to find out in which order they should be run. Is this information available somewhere?

Kind regards,  
Davide Aloi, PhD

---

<div class="post-metadata">

**Author:** ![DataNath](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/datanath/32/4070_2.png) [@DataNath](https://discourse.getdbt.com/u/DataNath)\
**Post date:** [December 11, 2024, 11:46am UTC](https://discourse.getdbt.com/t/dbt-compile-order-of-queries-to-run/17310/2 "2024-12-11T11:46:45Z")

</div>

Hey @DavideA, have you tried `dbt docs generate` followed by `dbt docs serve`?

---

<div class="post-metadata">

**Author:** ![DavideA](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DavideA](https://discourse.getdbt.com/u/DavideA)\
**Post date:** [December 11, 2024, 3:45pm UTC](https://discourse.getdbt.com/t/dbt-compile-order-of-queries-to-run/17310/3 "2024-12-11T15:45:55Z")

</div>

So currently I use the manifest.json to build the list of queries based on the depends\_on. This gives me a list of paths to each sql query. Now my question is, if I take that list, and run each query, would that give me the same output as dbt run? My goal is to use dbt to compile the queries and then run them separately.

Thanks a lot for your time

---

<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:** [December 12, 2024, 1:13am UTC](https://discourse.getdbt.com/t/dbt-compile-order-of-queries-to-run/17310/4 "2024-12-12T01:13:34Z")

</div>

> [@DavideA](#):
>
> My goal is to use dbt to compile the queries and then run them separately.

Can you share more context? Why is this a goal for you?

---

<div class="post-metadata">

**Author:** ![DavideA](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DavideA](https://discourse.getdbt.com/u/DavideA)\
**Post date:** [December 12, 2024, 8:56am UTC](https://discourse.getdbt.com/t/dbt-compile-order-of-queries-to-run/17310/5 "2024-12-12T08:56:27Z")

</div>

@joellabes Sure, sorry. I would like to generate all the compiled queries that dbt runs, without running them. This would include the materialisations, which to my understanding are not included in the compiled queries when running dbt compile. I would like to be able to run those queries as they are, outside dbt, and obtain the same outcome as if I ran dbt run. Is this feasible? Would I just need to edit the compiled queries inserting the SQL code as per the materialisation type of the model (i.e., create table / create view)?

---

<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:** [December 19, 2024, 2:29am UTC](https://discourse.getdbt.com/t/dbt-compile-order-of-queries-to-run/17310/6 "2024-12-19T02:29:21Z")

</div>

> [@DavideA](#):
>
> I would like to be able to run those queries as they are, outside dbt, and obtain the same outcome as if I ran dbt run.

This is the part I don’t understand - why is this a goal for you?

dbt’s capabilities as a string templater are _nice_, but normally people come to it for the rest of the experience (including executing nodes in the right order and not having to worry about whether nodes already exist etc for creating/dropping/modifying columns in existing tables).

> [@DavideA](#):
>
> materialisations […] are not included in the compiled queries when running dbt compile

This is correct - dbt compile will not wrap the queries in the appropriate DDL.
