How View Materializations Work
When you materialize a model as a view, dbt creates or replaces a view in your warehouse. During each run, dbt:- Creates or replaces the view definition using your model’s SQL
- Stores the query definition, not the actual data
- When queried later, the view executes its underlying SQL on-demand
- No physical data storage – just the query definition
- Data is always up-to-date with source changes
- Queries run the entire transformation each time
- Build times are faster since no data is materialized
CREATE VIEW or CREATE OR REPLACE VIEW statement:
Views are ideal when you need real-time data or when build time is more important than query performance.
When to Use View Materializations
Views are particularly valuable for:Configuring View Materializations
Views can be configured at both the model and project level.Model-Level Configuration
Project-Level Configuration
staging/ directory to materialize as views.
Performance Considerations
Views have different performance characteristics across warehouses:
To apply specific view configurations, use the
config() function with appropriate parameters:
Advantages and Limitations
When to Consider Other Materializations
While views are powerful, consider alternatives when:- Query performance becomes critical (use tables)
- Transformations are complex and compute-intensive (use tables)
- View references lots of data but users only need recent records (use incremental models)
- Transformation is only a stepping stone for a single downstream model (use ephemeral)
Best Practices
- Default to Views: Start with views for most models and change only when needed
- Staging Models: Keep staging models as views for flexibility
- Query Optimization: Write efficient SQL to reduce runtime overhead
- Monitor Performance: Watch for slow-running views and consider materializing as tables
- Documentation: Clearly document performance expectations for view models