You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/developer/dbt-model-best-practices.mdx
+9-5Lines changed: 9 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,14 +10,14 @@ When building your dbt models for Lightdash, following these best practices will
10
10
11
11
When deciding between wide materialized tables and smaller normalized tables that require multiple joins, you're balancing trade-offs across three dimensions: **performance**, **self-serve usability**, and **analytical depth**.
12
12
13
-
There's no one-size-fits-all answer—the right approach depends on your team's needs and how you want to empower your users.
13
+
There's no one-size-fits-all answer. The right approach depends on your team's needs and how you want to empower your users.
14
14
15
15
### Wide tables vs. multi-join models
16
16
17
17
| Factor | Wide tables | Multi-join models |
18
18
|--------|-------------|-------------------|
19
-
|**Performance**| Generally faster—materialized at the grain you need for specific analyses | Joins computed at query time; mitigated by fanout protection |
20
-
|**Self-serve usability**| Easier for business users—all fields in one place, less overwhelming | Can be intimidating—10 joined tables on one page is a lot for most users |
19
+
|**Performance**| Generally faster since they're materialized at the grain you need for specific analyses | Joins computed at query time, though mitigated by fanout protection |
20
+
|**Self-serve usability**| Easier for business users with all fields in one place, less overwhelming | Can be intimidating since 10 joined tables on one page is a lot for most users |
21
21
|**Analytical depth**| May require multiple wide tables for different use cases | More flexible for complex analyses across multiple dimensions |
22
22
23
23
### When wide tables work best
@@ -37,7 +37,7 @@ Modern columnar data warehouses (like Snowflake, BigQuery, and Redshift) are opt
37
37
38
38
Some analyses genuinely require multiple joins. For example, analyzing Bookings while filtering by an upstream dimension (like organic SEO traffic source) and breaking down by a downstream dimension (like a specific location) will likely require joins to be correct.
39
39
40
-
Lightdash handles multi-join explores well technically—[fanout protection](/references/joins#many-to-many-or-one-to-many-with-fanout-protection) ensures accuracy. However, looking at a page with many joined tables can be overwhelming for business users who aren't familiar with the data model.
40
+
Lightdash handles multi-join explores well technically, and [fanout protection](/references/joins#many-to-many-or-one-to-many-with-fanout-protection) ensures accuracy. However, looking at a page with many joined tables can be overwhelming for business users who aren't familiar with the data model.
41
41
42
42
### Common approaches
43
43
@@ -161,7 +161,11 @@ Pre-aggregates are especially useful for:
161
161
- Commonly used metric combinations
162
162
- Time-series data at standard intervals (daily, weekly, monthly)
163
163
164
-
The trade-off is maintenance overhead—you need to keep pre-aggregates in sync with your source data and ensure users understand when to use them vs. the detailed tables.
164
+
You can implement pre-aggregates in two ways:
165
+
-**In Lightdash**: Use [Lightdash pre-aggregates](/references/pre-aggregates) to automatically cache aggregated results
166
+
-**In dbt or your warehouse**: Pre-join and materialize tables directly as dbt models or warehouse tables if you prefer to manage them outside of Lightdash
167
+
168
+
The trade-off is maintenance overhead. You need to keep pre-aggregates in sync with your source data and ensure users understand when to use them vs. the detailed tables.
0 commit comments