> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Documentation for the LowCardinality optimization for string columns

# LowCardinality(T)

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

<h2 id="syntax">
  Syntax
</h2>

```sql theme={null}
LowCardinality(data_type)
```

**Parameters**

* `data_type` — [String](/reference/data-types/string), [FixedString](/reference/data-types/fixedstring), [Date](/reference/data-types/date), [DateTime](/reference/data-types/datetime), and numbers excepting [Decimal](/reference/data-types/decimal). `LowCardinality` is not efficient for some data types, see the [allow\_suspicious\_low\_cardinality\_types](/reference/settings/session-settings#allow_suspicious_low_cardinality_types) setting description.

<h2 id="description">
  Description
</h2>

`LowCardinality` is a superstructure that changes a data storage method and rules of data processing. ClickHouse applies [dictionary coding](https://en.wikipedia.org/wiki/Dictionary_coder) to `LowCardinality`-columns. Operating with dictionary encoded data significantly increases performance of [SELECT](/reference/statements/select/index) 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](/reference/data-types/enum) when working with strings. `LowCardinality` provides more flexibility in use and often reveals the same or higher efficiency.

<h2 id="example">
  Example
</h2>

Create a table with a `LowCardinality`-column:

```sql theme={null}
CREATE TABLE lc_t
(
    `id` UInt16,
    `strings` LowCardinality(String)
)
ENGINE = MergeTree()
ORDER BY id
```

<h2 id="related-settings-and-functions">
  Related Settings and Functions
</h2>

Settings:

* [low\_cardinality\_max\_dictionary\_size](/reference/settings/session-settings#low_cardinality_max_dictionary_size)
* [low\_cardinality\_use\_single\_dictionary\_for\_part](/reference/settings/session-settings#low_cardinality_use_single_dictionary_for_part)
* [low\_cardinality\_allow\_in\_native\_format](/reference/settings/session-settings#low_cardinality_allow_in_native_format)
* [allow\_suspicious\_low\_cardinality\_types](/reference/settings/session-settings#allow_suspicious_low_cardinality_types)
* [output\_format\_arrow\_low\_cardinality\_as\_dictionary](/reference/settings/formats#output_format_arrow_low_cardinality_as_dictionary)

Functions:

* [toLowCardinality](/reference/functions/regular-functions/type-conversion-functions#toLowCardinality)

<h2 id="related-content">
  Related content
</h2>

* Blog: [Optimizing ClickHouse with Schemas and Codecs](https://clickhouse.com/blog/optimize-clickhouse-codecs-compression-schema)
* Blog: [Working with time series data in ClickHouse](https://clickhouse.com/blog/working-with-time-series-data-and-functions-ClickHouse)
* [String Optimization (video presentation in Russian)](https://youtu.be/rqf-ILRgBdY?list=PL0Z2YDlm0b3iwXCpEFiOOYmwXzVmjJfEt). [Slides in English](https://github.com/ClickHouse/clickhouse-presentations/raw/master/meetup19/string_optimization.pdf)
