Overview
How Cube actually picks a rollup
Pre-aggregations are not magic — there is a deterministic matching algorithm. For an incoming query Q, Cube looks at every pre-aggregation P on the cubes Q touches and asks:
- Are Q's measures a subset of P's measures? No → skip.
- Are Q's dimensions a subset of P's dimensions? No → skip.
- Is Q's time grain ≥ P's grain? (day-rollup can answer month, but not the reverse.)
- Are Q's filters compatible with P's filter constraints?
First match wins. If nothing matches, Cube falls back to the live SQL.
The three pre-aggregation kinds
| Kind | What it stores | When to use |
|---|---|---|
rollup | Pre-aggregated measures by dims+grain | 95% of cases |
original_sql | A snapshot of the base SQL | When you can't change the warehouse but want a refresh boundary |
rollup_join | Rollup of multiple cubes joined first | High-cardinality joins that always co-occur |
Refresh strategies
- Cron-style —
refresh_key: { every: '30 minute' }. Simple, predictable. - SQL key — refresh when
MAX(updated_at)changes. Cheap when the source table has a watermark. - Incremental — refresh only the latest partition. Mandatory at TB scale.