0Pricing
SQL Academy · Lesson

When to Pre-Aggregate

Decide between live aggregation, materialised views, and downstream OLAP — based on freshness and cost.

Three Strategies for Aggregate Queries

  • Live — recompute every time
  • Materialized — store and refresh periodically
  • Triggered/Cached — update incrementally on every change

Live Aggregation

Simple and always fresh:

SELECT user_id, COUNT(*) FROM orders WHERE status = 'paid' GROUP BY user_id;

All lessons in this course

  1. Plain Views: Logical Reuse
  2. Updatable Views and INSTEAD OF Triggers
  3. Materialized Views and REFRESH Strategies
  4. When to Pre-Aggregate
← Back to SQL Academy