# Faster String Aggregations with Dimension Tables

DevFeed: [Faster String Aggregations with Dimension Tables](<https://devfeed.tech/articles/faster-string-aggregations-with-dimension-tables-63561.md>)

Original publisher: [Read original article](<https://duckdb.org/2026/10/02/dimension-tables.html>)

Author: DuckDB Team

Published: 2026-10-02T00:00:00Z

Content type: tutorial

Language: en

Sources: [DuckDB](<https://devfeed.tech/sources/duckdb.md>)

Topics: [Test-driven development](<https://devfeed.tech/topics/tdd.md>), [JOIN](<https://devfeed.tech/topics/join.md>), [table-partitioning](<https://devfeed.tech/topics/table-partitioning.md>)

Tags: [aggregate](<https://devfeed.tech/tags/aggregate.md>), [data](<https://devfeed.tech/tags/data.md>), [datasets](<https://devfeed.tech/tags/datasets.md>), [join](<https://devfeed.tech/tags/join.md>), [query](<https://devfeed.tech/tags/query.md>), [table](<https://devfeed.tech/tags/table.md>), [using-duckdb](<https://devfeed.tech/tags/using-duckdb.md>)

## AI overview

This DuckDB tutorial shows how to speed up repeated aggregations on long, low-cardinality strings by assigning sorted, narrow integer keys in dimension tables, grouping on those keys, and joining the strings back after aggregation. It explains alternatives such as ENUM, handling new values, tradeoffs, and cases where encoding is unlikely to help. It also notes that encoding does not solve high-cardinality aggregation memory growth caused by per-thread group duplication.

## Source excerpt

When a query groups on long, repeated strings, move the strings into a small dimension table with sorted, narrow integer keys. Aggregate on the keys, then join the strings back in at the very end. The query works as before, though on small fixed-width integers instead of variable-length text.