Creating Views
Simple View
View with JOINs
Aggregated Views
Create views with GROUP BY for dashboard analytics:Managing Views
Querying Views
Query materialized views like regular collections - data is pre-computed and instant:Aggregation Operators
| Operator | Description |
|---|---|
$sum | Sum values across grouped records |
$avg | Average values |
$count | Count records in group |
$countDistinct | Count unique values |
$min | Minimum value in group |
$max | Maximum value in group |
Use Cases
Analytics Dashboard
Leaderboard
Denormalized Feed
Performance Benefits
| Aspect | Regular Query | Materialized View |
|---|---|---|
| Complex JOINs | Computed per request | Pre-computed |
| Aggregations | Full table scan | Pre-calculated |
| Response time | Variable | Instant |
| Cost | Per-query computation | Storage only |
When to Use Views
Use materialized views when:- Queries are complex (multiple JOINs, aggregations)
- Data is queried frequently
- Real-time freshness is not critical
- Dashboard or analytics scenarios
- Data must be real-time fresh
- Queries are simple
- Data changes frequently and views would need constant refresh