liveBook · Manning

Cardinality

As explained in Latency

Cardinality is the number of distinct values in a dataset or column.

Cardinality measures how many distinct values a dataset or column contains. It matters when choosing a key for horizontal partitioning: a high-cardinality column offers more opportunities to spread rows across partitions, while a key with only a few values can leave partitions unevenly sized. section 5.2.1

User IDs versus order status

A user ID column has high cardinality because each ID is distinct. An order-status column has low cardinality because it has only a few possible values, such as pending, shipped, delivered, and canceled. The latter offers fewer ways to distribute rows by key. section 5.2.1

High cardinality is not a guarantee of balanced load. Requests may concentrate on a few hot partitions, and skewed writes may grow some partitions faster than others. Those cases can require further partitioning, extra resources for busy partitions, or rebalancing. section 5.2.1

How Latency covers it

How deep it goes
Defines high and low cardinality with column examples and explains their effect on partition balance, without specifying a measurement procedure.
Examples
Contrasts distinct user IDs with the limited values of an order-status column.
What it assumes
Assumes familiarity with database tables and columns while defining cardinality from its distinct-value count.
What you can do after
Evaluate/understand it when comparing partition keys and distinguishing uneven data distribution from hot-partition workloads.
How it connects
Connects cardinality to horizontal partitioning, partition keys, data skew, hot partitions, and rebalancing.

Also explained in

Compare how 8 books explain cardinality →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Latency. The section links point to the parts of the book it draws on.