Configure Aggregates

What this covers
An aggregate is a pre-computed summary table stored in the query target. When a BI query matches an available aggregate, Tessallite reads from the summary instead of scanning the full fact table. This article covers the two ways aggregates are created, the manual configuration workflow, aggregate properties, and how the grain controls which queries an aggregate can serve.
Two ways aggregates are created
- Manual configuration — You define the aggregate explicitly: you choose the name, grain, measures, and refresh schedule. Manually created aggregates start protected, which means the Optimizer and Scheduler will not retire or replace them on their own. You can turn protection off from the aggregate card if you want the lifecycle to be able to retire or replace the aggregate (see Protection below).
- AI Optimizer auto-creation — The Optimizer analyses query patterns observed by the Gateway and creates aggregates automatically at grains it calculates will reduce the most query cost. Auto-created aggregates are unprotected by default, so the Optimizer can retire them if query patterns change. They are visible in the Canvas alongside manual aggregates.
Both types coexist in the same model. Manual aggregates give you explicit control over high-priority query patterns; auto-created aggregates fill in the gaps based on actual usage. You can protect or unprotect any aggregate from its card in the Aggregates panel.
Aggregate properties
| Property | Description |
|---|---|
| Name | Internal identifier for the aggregate. Used as the summary table name in the query target schema. |
| Grain (dimensions) | The set of dimensions that define the level of detail in the summary. Every distinct combination of dimension values becomes one row in the summary table. |
| Measures | The measures to include in the summary. Only measures defined in the model can be selected. |
| Refresh schedule | A cron expression or preset that controls when the Scheduler re-queries the source and overwrites the summary. |
How the grain controls query matching
Each aggregate card shows its recorded source-row count, stored-row count and Stored / source rows percentage. For example, 20 stored rows from 100 source rows show 20%. The comparison uses available counts; a missing count shows Unavailable, and the percentage is unavailable when the source count is zero. These numbers describe row reduction, not whether the aggregate will help a particular query. Showing them does not run another source scan or stop a build.
The Query Router matches an incoming query to an aggregate when the query's requested dimensions are a subset of the aggregate's grain and the requested measures are all present in the aggregate. A query asking for revenue by country and month matches an aggregate whose grain includes country and month — even if the aggregate also includes a region dimension that the query does not use. The router selects the aggregate with the smallest grain that still covers the query.
An aggregate stored at a finer or equal grain can answer a coarser query by rolling its rows up:
- SUM and COUNT are additive: the stored values are added together.
- MIN and MAX roll up by taking the minimum or maximum of the stored values. They can be re-aggregated, but they are not additive.
- AVG is never averaged again. At a coarser grain it is computed from the stored SUM and COUNT columns.
- COUNT DISTINCT, median, percentiles, and dispersion statistics are served only when the query's grain matches the aggregate's grain exactly.
An aggregate cannot answer a query at a finer grain than its own.
How aggregate builds use the model query
When an aggregate is created or refreshed, the Optimizer and Scheduler submit its semantic grain and measures to the Query Router's /api/v1/explain endpoint with force_route=source. The returned SQL is the SQL materialised in the target. This keeps the model query's source relations and join closure authoritative for both full and incremental refreshes; the build services do not construct a separate executable FROM/JOIN clause.
Cron schedule presets
| Preset | Cron expression | When it runs |
|---|---|---|
| Every hour | 0 * * * * | At the start of every hour |
| Every 6 hours | 0 */6 * * * | At 00:00, 06:00, 12:00, 18:00 UTC |
| Daily at 02:00 | 0 2 * * * | Once per day at 02:00 UTC |
| Weekly (Sunday 03:00) | 0 3 * * 0 | Every Sunday at 03:00 UTC |
You can enter any valid cron expression in the schedule field if none of the presets match your requirements. All times are interpreted as UTC.
The Aggregate Drawer
Manual aggregate work — both creation and editing — happens in the Aggregate Drawer: a right-anchored 720 px panel with three tabs.
| Tab | Purpose |
|---|---|
| Definition | Target, grain (dimensions), measures, include-quantiles toggle, status. |
| Schedule | Cron picker plus the Schedule enabled switch and the recent run history. |
| Advanced | Read-only metadata — physical table name, status, created timestamp, retired timestamp, estimated hit rate, creation reason, AI rationale, invalid reason. |
In edit mode the drawer header carries a Refresh now button that triggers an immediate full rebuild (the Scheduler endpoint runs the same job a cron tick would have run). Closing the drawer with unsaved changes prompts for confirmation. The header also carries an Expand panel button (double arrow, next to the close button) that widens the drawer to the full window; click it again to retract.
Authoring workflow (create)
- Open the model in Model Builder. Confirm that a query target is set under Settings before proceeding — aggregates cannot be built without a target.
- Click Aggregates in the Toolbelt.
- Click New. The Aggregate Drawer opens on the Definition tab.
- Pick a Target (where the summary table is stored).
- Select the Grain (dimensions). Every distinct combination of dimension values becomes one row in the summary table. Dimensions whose value is functionally equivalent to another dimension's value (a redundant partner) are disabled with a tooltip explaining why.
- Select the Measures to include. The default aggregation function (
SUM,AVG, etc.) shown next to each measure name is what will be computed at create time. Non-additive measures are flagged with a chip. - Optionally enable the advanced statistical columns: Include median column (p50) — lets the router serve
MEDIAN(the 50th percentile) queries from the aggregate. Other percentiles (p90, p95, p99, and so on) are temporarily not materialised while percentile query routing is being completed; those queries return the correct answer from the source table in the meantime. And Include dispersion-stat columns (STDDEV_POP, STDDEV_SAMP, VAR_POP, VAR_SAMP) — lets the router serve standard-deviation and variance queries. Both are opt-in because they add extra columns per numeric measure, and both can only be served at the aggregate's exact grain. - The Aggregate estimate card appears live as you change selections, showing the ROI score and any non-additive warnings.
- Switch to the Schedule tab. Turn the Schedule enabled switch on, pick a cron expression with the picker, then click Save.
- The aggregate is queued for an initial build by the Scheduler. The card shows status pending and changes to fresh once the first build completes; only a fresh aggregate answers queries.
The first build runs as soon as the Scheduler picks up the job, typically within one minute. If the status stays pending for more than five minutes, check the Diagnostics panel for Scheduler errors.
Edit mode
Editing scope is intentionally narrow:
- Editable — schedule (cron + enabled), status (fresh / disabled / retired), include-quantiles and include-stats toggles, protection toggle (lock icon on the card), refresh-now trigger.
- Read-only — target, grain, measures. The drawer renders these as static chips with the note "To change the shape, delete this aggregate and create a new one." Aggregate shape changes go through delete-and-recreate so the physical table identity matches the definition.
Administrative API clients can change target_schema. Moving an aggregate to another target schema marks it stale and clears its last-refresh timestamp. The query router withholds it until a full rebuild succeeds at the new location; submitting the current target schema again does not invalidate the build.
The Definition tab shows the AI rationale card when the aggregate was created by the AI optimiser. The Advanced tab exposes the rest of the metadata.
The footer carries a Delete button (left) that asks for confirmation before retiring the aggregate and dropping its physical table.
When an aggregate no longer fits the model
An aggregate only makes queries faster. It is never part of the model's validity: whatever happens to an aggregate, the model stays valid, every query still runs, and every answer is the same. Only the time it takes changes.
An aggregate stops fitting the model when something it was built on is gone: a measure it holds was deleted, a dimension in its grain was removed, or the join that reached one of its tables was deleted. Tessallite then disables the aggregate and shows the reason on its card and in the drawer. A disabled aggregate answers no query and is not rebuilt, so it costs nothing while you decide. You cannot enable it while it still does not fit; the refusal names the reason.
What happens next depends on what you do with the model:
- You correct the model (for example, you add the join back). The aggregate returns to service by itself; there is nothing to click.
- You deploy the model as it is. A deployment is a change of model version, so every aggregate is checked against the new version. The ones that no longer fit are retired and their tables are dropped. The optimiser then proposes replacements from the workload, as it does for any new version.
- The aggregate is protected, or you created it by hand. It is never retired automatically. It stays disabled with its reason until you correct the model or delete the aggregate.
An aggregate you disabled yourself is a different case: it carries no reason, and Tessallite never switches it back on.
Every deployment and every revert also rebuilds the aggregates that still fit, because a formula or a setting may have changed between versions. Until an aggregate's rebuild has finished it answers no query and the query is answered from the source: slower for a short time, never a number from the previous version.
Expect a short warm-up window after every deployment, even when nothing in the model changed: for a few seconds the query router has not yet loaded the new version's aggregates, so queries are answered from the source while the aggregate cards still show them as active. Numbers are the same; only speed differs. Measure acceleration a little after a deployment, not in the first seconds.
Grain keys the build could not link to the model
Each grouping in an aggregate's grain is stored with the model columns it comes from. Tessallite only serves a query from an aggregate when it can prove that the query's grouping and the stored grouping are the same thing; a name alone is never proof. When a build cannot link a grouping to model columns, the card names it: "Queries grouped by business_date_year cannot use this aggregate". Queries that need that grouping are answered from the source, with the same numbers, only slower. The aggregate stays healthy and still serves the queries it can prove.
Example: a grain built on "year of the business date" is stored as the expression EXTRACT(YEAR FROM business_date). Tessallite links it to the business_date column, so a query grouped by that year is served from the aggregate. A year never borrows from a finer grouping: a month-grain aggregate does not answer a year query, and January of two years never share one total.
If the card shows such a key, correct the model column it should come from, then rebuild the aggregate.
How aggregates store data
Each measure included in an aggregate generates multiple physical columns in the summary table. This allows the Query Router to serve a wider range of SQL functions from the same aggregate without re-scanning the source.
| Measure type | Physical columns created |
|---|---|
| SUM measure | sum, count, min, max |
| AVG measure | avg, sum, count, min, max |
| COUNT measure | count, min, max |
| MIN measure | min, count, max |
| MAX measure | max, count, min |
| Any numeric measure, Include quantiles on | adds p50 (the median). Other percentiles are temporarily not materialised while percentile routing is completed. |
| Any numeric measure, Include stats on | adds stddev_pop, stddev_samp, var_pop, var_samp |
See Known limitations: data types and numbers on another connection for stored types and numeric differences.
AVG. An AVG measure stores an avg column, as the table shows. That column is used only when the query's grain matches the aggregate's grain exactly. At any coarser grain, AVG is computed from the stored sum and count columns (SUM / COUNT), never by averaging the stored averages.
COUNT(*). Every aggregate automatically includes a row-count column so that COUNT(*) queries can be served directly.
Median, percentile, and dispersion stats. MEDIAN/PERCENTILE_CONT/PERCENTILE_DISC, STDDEV_*, and VAR_* are not re-aggregatable — the median of two groups is not the median of their union. The median (p50) and the dispersion stats can be served from an aggregate, but only when the aggregate was built with the Include quantiles and/or Include stats option and the query's grain matches the aggregate's grain exactly (no coarser roll-up). Non-median percentiles (p90, p95, p99, and the rest) are temporarily served from the source even when the quantiles option is on: the routing that maps an arbitrary PERCENTILE_CONT/PERCENTILE_DISC fraction to a stored column is still being completed, so materialising those columns would only add storage and refresh cost without speeding any query up. They are not built for new aggregates yet; the answers stay correct — they just come from the source table. At any coarser grain, or when the columns were not materialised, the Query Router sends the query to the source table.
Exactness depends on the source engine: PostgreSQL and Redshift quantiles are exact, whatever target the aggregate is built in; Spark quantiles are exact for a same-engine refresh (Spark source and Spark target) but a cross-engine refresh cannot guarantee exact quantiles, so they are not materialised and such queries go to the source; BigQuery, Snowflake, and SQL Server have no exact percentile that an aggregate build can use (BigQuery offers exact percentiles only as window functions, SQL Server likewise), so for these sources the median column is not built, even with Include quantiles on; the rest of the aggregate builds normally and percentile queries go to the source for an exact answer. Standard deviation and variance are exact on PostgreSQL, Spark, and BigQuery.
Functions that always hit the source. Order-dependent or distribution-shaped functions — MODE, STRING_AGG/ARRAY_AGG/LISTAGG, and APPROX_COUNT_DISTINCT — cannot be served from pre-computed columns and always route to the source table.
On Redshift, PostgreSQL STRING_AGG is refused because LISTAGG drops empty strings and treats trailing spaces differently with DISTINCT. Use a source with native STRING_AGG support when those results are needed. Redshift averages preserve exact inputs when their bounded numeric type is known; an unknown type needs an explicit BIGINT or DECIMAL(p,s) cast. A decimal with no room for fractional widening is refused rather than converted to floating point.
Include all measures. This model setting is on by default, and new models start with it on. With it off, each summary table holds only the measures the queries that triggered it actually asked for. Existing models keep their saved setting.
When enabled, each summary includes eligible measures that fit the same grouping and row population, so more questions can reuse it. The trade is size and build time, and one subtler cost worth understanding.
Why "all measures" is not always better. A summary table is only allowed to answer a question when it was built over exactly the same set of rows the question would have scanned. Adding a measure that lives on a different table pulls that table into the summary's build, and if joining it drops or duplicates rows, the summary now covers a different population — so Tessallite refuses to answer from it and quietly goes back to the source table. Switch the setting on for a model with measures spread across several tables and you can end up with many summary tables that are never used. Tessallite guards against this automatically: when the setting is on, it only adds the measures that fit the same population as the query that triggered the build.
Existing summary tables when you change the setting. Nothing is destroyed the moment you flip the switch.
- Turning it on — the next Optimizer sweep rebuilds each live, unprotected summary table with the wider set of measures. Protected aggregates are left as they are.
- Turning it off — new summary tables are built narrow from then on. Summary tables you already have keep every column they were built with, so no report that relies on them stops working. Where an old wide table cannot answer a question, the Optimizer builds a narrow one next to it rather than replacing it — the wide table may still be the right answer for a report that asks for all of those measures at once. Tessallite does not delete the old table for you: it stays until the model's summary-table limit pushes it out, or until you retire it yourself from the Aggregates panel.
Tip. If you turned the setting off because a model had many summary tables that were never being used, check the Aggregates panel a few days later. The new narrow tables will show hits; the old wide ones that show none are safe to retire by hand.
If a new measure is added to the model while the setting is on, the lifecycle sweep detects the gap, retires the stale summary table, and rebuilds it — keeping the columns it already had and adding the missing ones. Protected aggregates are not rebuilt this way.
Enriched aggregates (removed)
Enriched aggregates stored a dimension's detail column (for example country_name) beside its key so that name-grouped queries could be relabelled from a key-grain aggregate. The relabel route was retired and attribute relationships were removed on 2026-10-01: no aggregate stores detail columns any more, and an aggregate built with them is rebuilt without them on its next refresh. A query grouped by country_name is served by an aggregate whose grain includes country_name. See Dimension Attribute Relationships.
Manual versus auto-created aggregates
Manual aggregates are displayed in the Canvas with a solid border on their dashed outline. Auto-created aggregates show an Optimizer badge. Both respond to the same status indicators (Ready, Stale, Refreshing, Error).
Protection. Every aggregate has a protection setting you can see and change from its card in the Aggregates panel. A protected aggregate (shown with a lock icon) cannot be retired, replaced, or evicted by any automated process — the include-all-measures backfill, the idle-retirement sweep, the predictive feedback loop, and the cap-enforcement policy all skip it. You can still retire or delete a protected aggregate yourself.
Manually created aggregates start protected; demand-driven and predictive aggregates start unprotected. You can change this at any time: click the lock icon on the card, then click Save. Protecting a demand aggregate that is working well keeps it safe from future cap eviction.
Unprotecting a manual aggregate makes it eligible for cap eviction and for the include-all-measures rebuild. The idle-retirement sweep still skips it, because manual aggregates are idle-retired only when the model setting Retire manual aggregates when idle is on. That setting applies whether or not the aggregate is protected; a protected aggregate is never idle-retired.
Protection and the aggregate limit. Protected aggregates are outside the model's maximum number of aggregates: they are not counted toward it and are never retired to make room. The limit applies only to unprotected aggregates. When a new unprotected aggregate would exceed it, Tessallite retires the lowest-value unprotected aggregates first. Creating a protected aggregate never retires anything. The never_evict eviction policy turns the limit off: new aggregates are created and nothing is retired. A disabled aggregate, such as an AI proposal waiting for review, does not count toward the limit. Enabling it counts like creating one: the same retirement rule makes room, or the switch is refused while the room is held by a rebuild.
An unprotected aggregate that is being rebuilt still holds its place in the limit, because it returns to service when the rebuild finishes. It is never retired while it is rebuilding. If the only way to make room would be to retire aggregates that are being rebuilt, the new aggregate is refused with a message to retry after the rebuild completes; nothing is retired. Example: with a limit of 1, while the only aggregate is refreshing, creating a second unprotected aggregate is refused until the refresh ends. An aggregate whose last rebuild failed, with no rebuild running, is not waiting on anything: it still counts against the limit, but it is retired first, before any aggregate that is serving queries. Example: with a limit of 1, if the only aggregate's rebuild failed, creating a second unprotected aggregate retires the failed one.
Retired aggregates and Purge. A retired aggregate stops serving queries straight away. Tessallite records the retirement first and then drops the summary table from the target immediately. If that drop fails (for example, the target is briefly unreachable), the retirement sweep retries it on every run. The retired definition stays in the Aggregates panel as a record. To remove it, click Purge on its card; this deletes the definition and any summary table that is still present.
Older than model data
An aggregate whose last refresh is earlier than the model's Data refreshed date shows Older than model data on its card. It still serves matching queries; its totals reflect an older read of the source than the rest of the model, so a query it answers can differ from one answered by a fresher object. Rebuild it, or align its schedule, when reports must agree. See Model details.
Deleting an aggregate
Deleting an aggregate removes both halves: the definition you see in Tessallite and the summary table it built on your target database. Tessallite records what needs removing before it deletes the definition, deletes the definition, and only then drops the table — in that order, so there is never a moment where Tessallite still thinks it can answer from a table that has already gone.
If the drop itself does not succeed (the target database is briefly unreachable, for example), the delete still goes through and the table is dropped on a later retry — the record of what to remove is kept.
One case is refused rather than half-done: if Tessallite cannot work out where the summary table actually lives — its target connection has been deleted, or now belongs to a different project — you get an error asking you to repair the connection first, and the aggregate is left alone. Deleting it at that point would leave a table on your database with nothing left in Tessallite pointing at it.