0
0
dbtdata~5 mins

Cross-team model sharing in dbt - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Cross-team model sharing
O(n)
Understanding Time Complexity

When teams share dbt models, it's important to know how the work grows as more models and teams join.

We want to see how the time to build or update models changes with more shared models.

Scenario Under Consideration

Analyze the time complexity of the following dbt model sharing setup.

-- models/team_a/model_a.sql
select * from source_table

-- models/team_b/model_b.sql
select * from {{ ref('model_a') }}

-- models/team_c/model_c.sql
select * from {{ ref('model_b') }}

This shows three teams sharing models where each model depends on the previous team's model.

Identify Repeating Operations

Look for repeated steps in building models across teams.

  • Primary operation: Running each model's SQL query once per build.
  • How many times: Once for each model in the dependency chain.
How Execution Grows With Input

As the number of shared models grows, the total work grows too.

Input Size (n models)Approx. Operations (model runs)
33
1010
100100

Pattern observation: The total work grows directly with the number of models shared.

Final Time Complexity

Time Complexity: O(n)

This means the time to build all shared models grows in a straight line as more models are added.

Common Mistake

[X] Wrong: "Sharing models means the build time stays the same no matter how many models there are."

[OK] Correct: Each model still needs to run once, so more models mean more total work.

Interview Connect

Understanding how shared models affect build time helps you explain teamwork impact on data pipelines clearly and confidently.

Self-Check

What if models were built in parallel instead of one after another? How would the time complexity change?