---
title: "OLAP cube"
description: "An OLAP cube is a multidimensional data structure that pre-aggregates measures across combinations of dimensions, letting users slice, dice, drill down, and roll up data quickly without recomputing aggregations each time."
canonical: "https://motherduck.com/glossary/olap-cube/"
related:
  - title: "DuckLake Architecture Deep Dive"
    url: "https://motherduck.com/blog/ducklake-architecture-deep-dive/"
  - title: "Business Intelligence Tools | MotherDuck Docs"
    url: "https://motherduck.com/docs/integrations/bi-tools/"
  - title: "Simplicity of a Database, but the Speed of a Cache: OLAP Caches for DuckDB"
    url: "https://motherduck.com/blog/duckdb-olap-caching/"
---

# OLAP cube

> An OLAP cube is a multidimensional data structure that pre-aggregates measures across combinations of dimensions, letting users slice, dice, drill down, and roll up data quickly without recomputing aggregations each time.

## Overview

An OLAP cube organizes data along multiple dimensions (time, product, region, customer) with measures (revenue, quantity) at their intersections — conceptually a multidimensional array, though most implementations don't literally store an N-dimensional array. Classic OLAP cube operations include:

- **Slice**: fix one dimension to a single value (e.g., only 2026 data).
- **Dice**: filter to a sub-cube across multiple dimensions at once.
- **Drill down / roll up**: move between levels of a dimension's hierarchy (year → quarter → month, or region → country → city).
- **Pivot**: rotate the cube to view it from a different dimensional axis.

Traditional OLAP engines (MOLAP) pre-compute and store aggregations at every level of every dimension hierarchy so these operations return instantly. ROLAP engines skip pre-computation and query a relational star schema directly, computing aggregations on demand. HOLAP mixes the two.

<glossary-callout guide="duckdb-book-brief" />

### The relational equivalent

A star schema queried with `GROUP BY` is the relational (ROLAP) way to get the same result a cube provides, computed on demand rather than pre-materialized:

```sql
-- Roll up
SELECT region, SUM(revenue) FROM fact_sales JOIN dim_date USING (date_key)
WHERE year = 2026 GROUP BY ALL;

-- Drill down
SELECT region, quarter, SUM(revenue) FROM fact_sales JOIN dim_date USING (date_key)
WHERE year = 2026 GROUP BY ALL;

-- Slice + dice
SELECT product_category, SUM(revenue) FROM fact_sales
JOIN dim_date USING (date_key) JOIN dim_product USING (product_key)
WHERE year = 2026 AND region = 'EMEA' GROUP BY ALL;
```

`ROLLUP` and `GROUPING SETS` extend standard SQL `GROUP BY` to compute several aggregation levels from a hierarchy in a single query, closely mirroring cube drill-down/roll-up.

### DuckDB angle

DuckDB doesn't provide a dedicated MOLAP cube structure, but its fast, vectorized aggregation over a star schema makes the ROLAP pattern above practical to compute on demand rather than pre-materializing every level: `SUM`/`GROUP BY ALL` queries against a fact table joined to its dimensions typically return in milliseconds to seconds even over large tables, and DuckDB supports standard SQL `GROUPING SETS`/`ROLLUP`/`CUBE` for multi-level aggregation in one query.
