View Materialization
A view materialization is dbt's default method for creating models. Instead of storing data physically like a table, a view is a saved SQL query that executes each time you access it. This means:
Views always show the latest source data
No additional storage is required
The transformation logic runs on every query
If you don't specify a materialization, dbt will create your model as a view by default.
Working with Views
Let's understand views through a simple example:
When someone queries this view:
The warehouse executes the underlying SQL
Results reflect the current data in raw_orders
No data is stored permanently
Under the hood, dbt™ executes a CREATE VIEW
or CREATE OR REPLACE VIEW
statement:
When to Use Views
Views are ideal for:
Simple transformations (renaming columns, basic calculations)
Staging models that clean and prepare source data
Development and testing before optimization
Real-time data requirements
Configuration
Views can be configured in your model files or project configuration.
Model-Level Configuration
Project-Level Configuration
Performance and Usage Guidelines
Advantages and Limitations
🔄 Always reflects current source data
🐌 Can be slow for complex transformations
💰 No storage costs
🏋️ Resource-intensive for frequent queries
🛠️ Easy to modify and test
⚠️ Not ideal for nested views
🎯 Simple to maintain
When to Change Materialization
Consider changing from a view when you encounter:
Slow query performance
High computation costs
Frequent access patterns
Complex transformations
Best Practices
Start with Views: Begin with views and change only when needed
Monitor Performance: Track query times and resource usage
Optimize Strategically: Limit nesting, use tables for complex analytics
Views are ideal for development and simple transformations. Switch to other materializations only when performance requirements demand it.
Last updated
Was this helpful?