
Unlock this content
Enter your email to unlock this content for free
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;