LowCardinality Data Type

Changes the internal representation of other data types to be dictionary-encoded.

Syntax

  1. LowCardinality(data_type)

Parameters

Description

LowCardinality is a superstructure that changes a data storage method and rules of data processing. ClickHouse applies dictionary coding to LowCardinality-columns. Operating with dictionary encoded data significantly increases performance of SELECT queries for many applications.

The efficiency of using LowCardinality data type depends on data diversity. If a dictionary contains less than 10,000 distinct values, then ClickHouse mostly shows higher efficiency of data reading and storing. If a dictionary contains more than 100,000 distinct values, then ClickHouse can perform worse in comparison with using ordinary data types.

Consider using LowCardinality instead of Enum when working with strings. LowCardinality provides more flexibility in use and often reveals the same or higher efficiency.

Example

Create a table with a LowCardinality-column:

  1. CREATE TABLE lc_t
  2. (
  3. `id` UInt16,
  4. `strings` LowCardinality(String)
  5. )
  6. ENGINE = MergeTree()
  7. ORDER BY id

Related Settings and Functions

Settings:

Functions:

See Also