GregM
05/28/2026, 8:38 PMRocky
05/28/2026, 8:39 PMSTRING and a large VARCHAR like VARCHAR(1048576) is the maximum allowed length and how the system manages memory during query execution.
1. Maximum Length
* STRING: In StarRocks, STRING is essentially an alias for VARCHAR(65533). Its maximum length is 65,533 bytes.
* VARCHAR(1048576): Since StarRocks v2.1, the maximum length for VARCHAR has been increased to 1,048,576 bytes (approximately 1 MB).
* Note: Both types measure length in bytes, not characters. In UTF-8, a single character (like a Chinese character) can take 3–4 bytes.
2. Storage vs. Memory Performance
* Storage: There is no difference in disk storage. Both are variable-length types, meaning if you store the word "Rocky" in a VARCHAR(1048576) column, it only consumes the bytes needed for that string, not the full 1 MB.
* Memory Allocation: This is where the difference matters. In some query scenarios, StarRocks pre-allocates memory based on the defined length of the column rather than the actual data size.
* Using VARCHAR(1048576) for every column can lead to higher memory overhead and potentially "out of memory" (OOM) errors during complex joins or aggregations because the execution engine may prepare for the worst-case scenario (1 MB per row).
* Using STRING (which is 64KB) is safer for memory than the 1MB max, but still larger than a targeted VARCHAR(N).
3. Summary Comparison
Feature | STRING | VARCHAR(1048576)
Max Size | 65,533 bytes (~64 KB) | 1,048,576 bytes (~1 MB)
Storage | Actual data length | Actual data length
Memory Risk | Moderate | High (if used excessively)
Usage | General-purpose text | Very long logs, JSON, or large text blobs
Recommendation
* Be precise: Use the smallest VARCHAR(N) that fits your data (e.g., VARCHAR(255) for names).
* Use STRING: If you know your data is under 64KB but don't want to define a specific limit.
* Use VARCHAR(1048576): Only when you specifically expect data to exceed 64KB. If you need even more space, you should consider the JSON type or storing data in an external system.
References
• knowledge/usage/best-practice.md
• sql-reference/data-types/string-type/VARCHAR.md
• faq/table_design_faq.md
• faq/Others.md
• sql-reference/data-types/string-type/STRING.md
• sql-reference/data-types/string-type/BINARY.md
• faq/Sql_faq.mdЕвгений Шишкин
05/28/2026, 8:47 PMtransform_type_prefer_string_for_varcharЕвгений Шишкин
05/28/2026, 8:48 PM