TapCub is live — analytics, insights and live chat, free on one platform
Glossary

Cardinality in data: what it is and why high cardinality matters

Cardinality is the number of distinct values in a set or field. What low and high cardinality mean for analytics properties, why high cardinality breaks reports, how to fix it in tracking and how distinct counts are estimated.

Chen Yu Reviewed by Lin Zhou Also called distinct count Last updated Nov 5, 2026 Glossary

Quick answer

Cardinality is the number of distinct elements in a set. In analytics it usually means how many distinct values a field or property holds (low for device type, high for user IDs or raw URLs); in data modeling it describes one-to-one, one-to-many or many-to-many relationships.

What is cardinality?

Cardinality is the number of distinct elements in a set. In data and analytics it has two everyday meanings:

  1. Column or property cardinality: how many distinct values a field holds. device_type (desktop, mobile, tablet) has low cardinality; user_id or a full page URL has high cardinality.
  2. Relationship cardinality in data modeling: how many rows in one table relate to rows in another, written one-to-one (1:1), one-to-many (1:N) or many-to-many (N:M).

In mathematics, cardinality is simply the size of a set, written |A|. The analytics meanings are applications of the same idea.

Low vs high cardinality

Sample event properties from a mid-sized product over 30 days (sample data):

PropertyDistinct valuesCardinalityGood as a report dimension?
device_type3LowYes
browser31LowYes
event_name64Low–mediumYes
country187MediumYes
page_path (template, e.g. /product/:id)420MediumYes
page_url (raw, with query strings)186,000HighNo
user_id92,000Very highNo, filter or count instead
session_id1,400,000Very highNo

The rule of thumb: group by low and medium cardinality, filter or count by high cardinality. Nobody can read a bar chart with 186,000 bars, and a breakdown where every row has one visit says nothing.

Why high cardinality causes problems

  • Unreadable reports. Breakdowns get truncated to the top values plus an "Other" bucket, and the long tail disappears.
  • Slower queries and higher cost. Grouping by a field with millions of values means sorting and hashing millions of keys. Columnar stores compress low-cardinality columns very well and high-cardinality ones poorly.
  • Fragmented metrics. If /pricing?utm_source=x and /pricing are different values, page metrics split across thousands of rows.
  • Privacy risk. Free-text and ID fields with unique values can identify people. Do not put emails or names into properties.

Fixing high cardinality in tracking

  • Normalize URLs into templates. Strip query strings and replace IDs: /order/83721 → /order/:id. Keep campaign data in UTM fields, not in the path.
  • Bucket continuous values. Send price_band: "50-100" alongside the exact amount if you need a dimension.
  • Keep IDs as identifiers, not dimensions. Use user_id to count distinct people and to identify users, not to group charts.
  • Use enumerations in your tracking plan. Define allowed values for each property so typos ("Mobile", "mobile ", "mob") do not create new values. See data taxonomy and data dictionary.

Counting distinct values: exact vs approximate

"How many unique users?" is a cardinality question. Exact COUNT(DISTINCT user_id) must remember every value it has seen, which is expensive at scale and cannot be added across days: a person active on Monday and Tuesday is one weekly user, not two. That is why weekly and monthly actives are computed over the whole window rather than summed from daily numbers; see DAU, WAU and MAU.

Many analytics databases offer approximate algorithms such as HyperLogLog, which estimate cardinality from a small fixed amount of memory. The typical relative error is about 1.04 ÷ √m, where m is the number of registers: with 16,384 registers that is roughly ±0.8%; with 4,096 it is ±1.6%. For dashboards that is usually fine; for billing or compliance counts, use exact counts.

Relationship cardinality in data models

TypeExample in analytics dataWatch out for
One-to-one (1:1)A user and their profile recordRare; often merged into one table
One-to-many (1:N)One user has many sessions; one session has many eventsJoining events to users repeats user fields on every event row
Many-to-many (N:M)Users and the accounts or workspaces they belong toNeeds a link table; naive joins double-count revenue

Database query planners also estimate "cardinality" in the sense of how many rows a step will return. Bad estimates lead to slow plans, which is why keeping statistics up to date matters.

In TapCub

TapCub merges page rows by path template in the heatmap list, groups breakdown charts into the top values plus "Other", and in event analysis shows only the more common values when a property has many. Distinct counts (visitors, people, active users) are computed over the selected window rather than summed per day. Under Data › Data quality, the High cardinality tab compares each property’s distinct values over the last 7 days with a threshold, lists keys that are already about halfway there, and lets you mark a property Export only so it stays in raw exports but out of report breakdowns. Tiered decay can also clear high-cardinality columns such as properties and referrer URL on old event rows while trends and funnels keep working. When you design properties, keep report dimensions low-cardinality and put IDs in identity fields. To add your own dimensions for grouping, see custom dimensions.

Sources

Was this explanation clear?

We use your answers to fix and expand this page.

Chen Yu

Technical Engineer

Focuses on tracking code, SDKs, and API integrations, with practical guidance on implementation checks and troubleshooting.

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What is high cardinality?

A field with a very large number of distinct values relative to its rows, such as user IDs, session IDs or raw URLs with query strings.

Why is high cardinality bad for analytics reports?

Breakdowns become unreadable and get truncated to top values, queries get slower and more expensive, and metrics fragment across thousands of near-duplicate values.

How do you reduce cardinality?

Normalize URLs into templates, bucket continuous values, define allowed values in a tracking plan, and use IDs for filtering and counting rather than grouping.

What is cardinality in a database relationship?

It describes how rows in two tables relate: one-to-one, one-to-many or many-to-many.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics