Home / Companies / Metabase / Blog / Post Details
Content Deep Dive

Making pivot tables faster with GROUPING SETS

Blog post from Metabase

Post Details
Company
Date Published
Author
Tamás Benkő
Word Count
1,767
Company Posts That Month
20
Language
English
Hacker News Points
-
Post removed?
No
Summary

Metabase 64 introduces an optional single-query approach to pivot tables that replaces the previous method of issuing separate database queries for every combination of detail rows, subtotals, and grand totals, a process that could require up to 32 queries for five grouping fields. Using the SQL-standard GROUPING SETS feature, supported databases can calculate all pivot levels in one scan while GROUPING() supplies the bitmask Metabase uses to position rows and totals in the rendered table. Benchmarks show the approach is often two to three times faster, and because detail and total values originate from the same query, it prevents inconsistencies caused by row-result limits that previously required Metabase to suppress subtotals when detail results were truncated. The feature supports many analytical SQL warehouses, including PostgreSQL, Snowflake, BigQuery, and Redshift, but databases without GROUPING SETS support, such as MySQL and SQLite, as well as pivots using window-function aggregations, continue to use the older multi-query path. Native pivot tables are disabled by default in version 64 while Metabase gathers real-world feedback, and self-hosted users can enable them through the MB_USE_NATIVE_PIVOT_TABLES setting.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
Subagents 1 166 67 37 -37%
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.