0
0
dbtdata~5 mins

PR review workflows for dbt changes - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: PR review workflows for dbt changes
O(n)
Understanding Time Complexity

When reviewing dbt changes in a pull request, it's important to understand how the time to check and test these changes grows as the project size increases.

We want to know how the review process scales with more models and tests.

Scenario Under Consideration

Analyze the time complexity of this simplified dbt PR review workflow snippet.


-- models/my_model.sql
select * from source_table

-- tests/my_model_test.sql
select count(*) from {{ ref('my_model') }} where id is null

-- dbt_project.yml
models:
  my_project:
    +materialized: table

-- PR review steps:
-- 1. Run dbt compile
-- 2. Run dbt test
-- 3. Review changed models and tests

This snippet shows a simple dbt model and test, with a typical PR review workflow running compile and test commands.

Identify Repeating Operations

In the PR review workflow, the main repeated operations are:

  • Primary operation: Running tests on each changed model.
  • How many times: Once per changed model and its tests.
How Execution Grows With Input

As the number of changed models increases, the time to run tests and review grows roughly in direct proportion.

Number of Changed Models (n)Approx. Review Time
1Short (few minutes)
10About 10 times longer
100About 100 times longer

Pattern observation: The review time grows linearly with the number of changed models and tests.

Final Time Complexity

Time Complexity: O(n)

This means the review time increases directly with the number of changed dbt models and tests.

Common Mistake

[X] Wrong: "Review time stays the same no matter how many models change."

[OK] Correct: Each changed model adds tests and code to check, so more changes mean more work and longer review time.

Interview Connect

Understanding how review time grows helps you plan and communicate better in real projects, showing you grasp practical workflow scaling.

Self-Check

"What if we only ran tests on models that actually changed instead of all models? How would the time complexity change?"