Mohan
08/10/2026, 6:00 PMRocky
08/10/2026, 6:00 PMVARCHAR(N) is interpreted:
* StarRocks: N represents the maximum length in bytes.
* MySQL: N represents the maximum length in characters (for versions 5.0.3 and later).
Key Implications
1. Multi-byte Characters:
* In StarRocks, if you use UTF-8 encoding, a single Chinese character or emoji can take 3 to 4 bytes.
* If you migrate a VARCHAR(10) column from MySQL that contains 10 Chinese characters, setting it to VARCHAR(10) in StarRocks will cause an "Arithmetic overflow" or data truncation error because 10 characters require at least 30 bytes.
2. Migration Rule of Thumb:
* When moving data from MySQL to StarRocks, a common practice is to triple or quadruple the VARCHAR length (e.g., MySQL VARCHAR(20) becomes StarRocks VARCHAR(60) or VARCHAR(80)) to ensure all multi-byte characters fit.
3. Maximum Length:
* StarRocks 2.1 and later: Supports up to 1,048,576 bytes (1 MB).
* StarRocks (older versions): Support up to 65,533 bytes.
* MySQL: Supports up to 65,535 bytes (shared across the entire row).
Performance Tip
While StarRocks allows very large VARCHAR lengths, it is recommended to set the length to a realistic maximum rather than just using the upper limit. This is because some query processing stages (like memory pre-allocation for certain operators) may use the defined length rather than the actual data length, which can impact memory-intensive queries if the lengths are excessively large.
References
• knowledge/usage/best-practice.md
• sql-reference/data-types/string-type/VARCHAR.md
• faq/Others.md
• faq/Sql_faq.md
• faq/table_design_faq.md
• sql-reference/data-types/string-type/CHAR.md
• sql-reference/data-types/string-type/STRING.mdMohan
08/10/2026, 6:04 PMRocky
08/10/2026, 6:04 PMVARCHAR(N) counts characters, a 4x multiplier (e.g., MySQL VARCHAR(20) → StarRocks VARCHAR(80)) guarantees that even a string of 20 emojis will fit.
When 3x is sufficient
* If your data is strictly standard text (English, Chinese, Japanese, Korean) and does not contain emojis, a 3x multiplier is sufficient. StarRocks documentation often uses 3x as the example for Chinese character migration.
Why you should avoid 5x (or larger)
While it might seem "safer" to go even higher, StarRocks has a specific reason to keep the length realistic:
* Memory Pre-allocation: For certain query operations (like some Joins or Group By), StarRocks may pre-allocate memory based on the defined length of the VARCHAR rather than the actual data size.
* Performance Hit: If you define columns as VARCHAR(500) when they only ever hold 20 characters, you risk higher memory consumption and potential "out of memory" (OOM) errors during complex queries on large datasets.
Recommendation
* Use 3x if you are sure there are no emojis (e.g., standard names, addresses).
* Use 4x if the field can contain any user-generated content (comments, social media posts).
* Avoid 5x+ unless you specifically expect the data length in the source to increase later.
Pro-tip: If you aren't sure, check your actual data in MySQL first:
sql
SELECT MAX(LENGTH(your_column)) FROM your_table; -- Returns size in bytes
This will tell you exactly what your current maximum byte usage is, allowing you to set an accurate size in StarRocks.
References
• knowledge/usage/best-practice.md
• faq/table_design_faq.md
• faq/Others.md
• sql-reference/data-types/string-type/VARCHAR.md
References
• knowledge/usage/best-practice.md
• faq/Others.md
• faq/Sql_faq.md
• faq/table_design_faq.md
• sql-reference/data-types/string-type/VARCHAR.md
• sql-reference/data-types/string-type/STRING.md
• sql-reference/data-types/string-type/CHAR.md