GregM
04/23/2026, 6:53 PMRocky
04/23/2026, 6:53 PMprimary_key_limit_size parameter in your be.conf (BE configuration). If you really need more, you can increase this value, though it will consume more memory and I/O.
To check the size of your fields before implementing them as a PK, you can use the following methods:
1. For String Fields (VARCHAR, CHAR)
StarRocks provides the length() function, which specifically returns the length of a string in bytes (unlike char_length(), which returns the number of characters).
You can run a query like this to see the maximum byte size currently used in your data:
sql
SELECT
MAX(length(your_column_name)) as max_bytes,
AVG(length(your_column_name)) as avg_bytes
FROM your_table;
2. For Fixed-Width Types
If you are using numeric or date types, they have fixed byte sizes regardless of the value:
* TINYINT: 1 byte
* SMALLINT: 2 bytes
* INT: 4 bytes
* BIGINT: 8 bytes
* LARGEINT: 16 bytes
* DECIMAL: 16 bytes
* DATE: 3 bytes
* DATETIME: 8 bytes
* BOOLEAN: 1 byte
3. Calculating Composite Primary Keys
If your PK consists of multiple columns, the total size is the sum of the byte sizes of each column. For example, if you have a PK consisting of an INT (4 bytes) and a VARCHAR that contains strings up to 20 bytes long, your total PK size would be 24 bytes.
Why does this matter?
The primary key index is stored in memory (unless you enable the Persistent Index). Smaller primary keys lead to:
* Lower memory consumption: Smaller keys mean more keys can fit in the same amount of RAM.
* Faster performance: Smaller keys are faster to compare and search during upsert/delete operations.
Pro-tip: If you find that your strings are too long but you still need them for uniqueness, consider if you can represent that data using a BIGINT or a shorter ID instead.
Let me know if you have more questions about your table design!
References
• sql-reference/sql-functions/string-functions/character_length.md
• sql-reference/sql-functions/string-functions/char_length.md
• faq/Others.md
• knowledge/usage/best-practice.md
• sql-reference/sql-functions/string-functions/length.md
• sql-reference/data-types/string-type/VARCHAR.md
• sql-reference/data-types/string-type/CHAR.mdGregM
04/23/2026, 6:55 PMprimary_key_limit_size param?Rocky
04/23/2026, 6:56 PMprimary_key_limit_size parameter (and other Backend configurations), you have a few options:
1. Using SQL (Recommended)
You can query the information_schema.be_configs table directly from your MySQL client. This is the easiest way to see the current effective value across all your BE nodes:
sql
SELECT * FROM information_schema.be_configs WHERE NAME = 'primary_key_limit_size';
2. Using the HTTP API
Each Backend (BE) node provides a /varz endpoint that lists all configuration parameters. You can use curl to check it:
bash
curl http://<BE_IP>:<BE_HTTP_PORT>/varz | grep primary_key_limit_size
_Note: The default <BE_HTTP_PORT> is usually 8040._
3. Checking the Configuration File
You can also check the configuration file on the server where the BE is running:
* Path: starrocks/be/conf/be.conf
* Open the file and look for primary_key_limit_size. If it's not listed, it is using the default value of 128 bytes.
──────────
Important Notes on the Limit:
* Default: 128 bytes.
* What it limits: This is the maximum size of the encoded primary key. If you have a composite PK, the limit applies to the total sum of the key columns' byte sizes.
* Mutable: This parameter is dynamic. You can change it without restarting the BE by using the curl command (though it's safer to update be.conf as well to make it persistent):
bash
curl -X POST http://<BE_IP>:<BE_HTTP_PORT>/api/update_config?primary_key_limit_size=256
Warning: Increasing this will increase memory usage for the Primary Key index.
References
• administration/management/BE_configuration.md
• sql-reference/information_schema/be_configs.md
• best_practices/primarykey_table.md
References
• administration/management/BE_configuration.md
• administration/management/FE_configuration.md
• sql-reference/sql-statements/cluster-management/config_vars/ADMIN_SHOW_CONFIG.md
• sql-reference/sql-statements/cluster-management/nodes_processes/SHOW_BACKENDS.md