Unlock this content

Enter your email to unlock this content for free

By continuing, you agree to our Terms of Service and Privacy Notice, and to receive occasional marketing emails.

Strings

TL;DR

Use FixedString(N) for fixed-length codes, LowCardinality(String) for categorical data (70-90% compression savings), and plain String as a fallback for variable-length text.

FixedString for Codes

For fixed-length strings (e.g., ISO country codes 'US', 'UK', 'DE'), FixedString(N) is more efficient than String. It uses exactly N bytes per value.

Variable length for fixed data:

CREATE TABLE users_bad ( country String ) ENGINE = MergeTree() ORDER BY country;

Tinybird is not affiliated with, associated with, or sponsored by ClickHouse, Inc. ClickHouse® is a registered trademark of ClickHouse, Inc.

Strings | ClickHouse for Developers