# Apply row Limits in Model runs in CI run

**URL:** <https://discourse.getdbt.com/t/apply-row-limits-in-model-runs-in-ci-run/7485>\
**Category:** In-Depth Discussions\
**Tags:** ci-cd, redshift\
**Created:** [March 27, 2023, 9:30am UTC](https://discourse.getdbt.com/t/apply-row-limits-in-model-runs-in-ci-run/7485 "2023-03-27T09:30:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chintanpatelTH](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@chintanpatelTH](https://discourse.getdbt.com/u/chintanpatelTH)\
**Post date:** [March 27, 2023, 9:30am UTC](https://discourse.getdbt.com/t/apply-row-limits-in-model-runs-in-ci-run/7485/1 "2023-03-27T09:30:03Z")

</div>

Hello I’ve implemented Slim CI with dbt-core. I have been running modified models whne PR is created or updated with following command.

`dbt run --defer --models state:modified+1 --state state_file_path`

I want to limit no of records in model runs to speed up CI. I have done it through custom source and ref macros. For example : [[Feature] "Slim CI" but with `LIMIT 0` · Issue #4201 · dbt-labs/dbt-core · GitHub](https://github.com/dbt-labs/dbt-core/issues/4201#issuecomment-1133630131)

Some of my models use dbt\_utils methods where it expects Relation object.  
Question : How would I apply limit in this case? Currently I pass relation parameter in my custom macro to return Relation object but I can’t limit the records.

Thanks!

---

<div class="post-metadata">

**Author:** ![Surya](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/surya/32/3763_2.png) [@Surya](https://discourse.getdbt.com/u/Surya)\
**Post date:** [March 27, 2023, 11:58am UTC](https://discourse.getdbt.com/t/apply-row-limits-in-model-runs-in-ci-run/7485/2 "2023-03-27T11:58:43Z")

</div>

> [@chintanpatelTH](#):
>
> case

can you send us the **dbt\_utils** methods you are using in your model files and are causing issues

---

<div class="post-metadata">

**Author:** ![chintanpatelTH](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@chintanpatelTH](https://discourse.getdbt.com/u/chintanpatelTH)\
**Post date:** [March 27, 2023, 12:29pm UTC](https://discourse.getdbt.com/t/apply-row-limits-in-model-runs-in-ci-run/7485/3 "2023-03-27T12:29:41Z")

</div>

Hello @Surya,

For example : dbt\_utils.deduplicate [dbt-utils/deduplicate.sql at main · dbt-labs/dbt-utils · GitHub](https://github.com/dbt-labs/dbt-utils/blob/main/macros/sql/deduplicate.sql)

```auto
dbt_utils.deduplicate(
            relation=source('schema', 'table'),
            group_by="col1",
            order_by="col2 desc",
        )

```
