Jacopo Gobbi
07/03/2026, 4:11 PMRocky
07/03/2026, 4:11 PMJacopo Gobbi
07/03/2026, 4:12 PMRocky
07/03/2026, 4:13 PMpersistent_index, the index is stored on disk (usually SSD). This allows you to have primary keys larger than your RAM, but it introduces disk I/O into the ingestion path, further widening the performance gap between it and the Duplicate Key model.
3. Backpressure and Throttling
Primary Key tables are much more sensitive to "Write Amplification" caused by compaction.
* Duplicate Key: Compaction is simpler (base-rowset merging).
* Primary Key: Compaction must manage both data and Delete Vectors. If you ingest too fast, the "compaction score" will rise. StarRocks will intentionally throttle or pause ingestion for Primary Key tables to prevent query performance from degrading. Duplicate Key tables are much harder to "choke" in this manner.
Summary: When to choose which?
Scenario | Use Duplicate Key | Use Primary Key
Data Nature | Raw logs, immutable events | CDC data, orders, user profiles
Ingestion Priority | Absolute max throughput | Maintaining uniqueness/updates
Query Priority | Filtering/Scanning efficiency | Point lookups, high-concurrency "latest value"
Hardware | Optimized for I/O | Requires more RAM/Fast SSD for index
Bottom Line: If your data is truly append-only and you don't need the database to enforce uniqueness or handle updates, Duplicate Key will always be faster and more resource-efficient for ingestion. Using a Primary Key table "just in case" for append-only data is considered a StarRocks anti-pattern because of the unnecessary index and compaction overhead.
References
• table_design/table_types/primary_key_table.md
• best_practices/primarykey_table.md
• table_design/table_types/duplicate_key_table.md
References
• table_design/table_types/primary_key_table.md
• best_practices/primarykey_table.md
• table_design/table_types/duplicate_key_table.mdJacopo Gobbi
07/03/2026, 4:14 PMRocky
07/03/2026, 5:25 PMlake_ingest_slowdown_threshold (default: 100), the FE will intentionally delay the commit of new transactions.
* Log/Error Evidence: You will see messages like:
Partition's compaction score is larger than 100.0, delay commit for 6513ms.
* Hard Stop: If the score exceeds lake_compaction_score_upper_bound (default: 2000), the system will outright reject the load with:
Failed to load data... because of too large compaction score.
2. Version Limits (Shared-nothing Clusters)
In standard (Shared-nothing) clusters, the mechanism is a hard limit on the number of "versions" (data segments) a tablet can hold before they are compacted.
* Mechanism: If ingestion is too frequent (e.g., many small batches), the number of versions will hit the tablet_max_versions limit (default: 1000).
* Result: The ingestion fails with:
Failed to load data into tablet xxx, because of too many versions.
Why Primary Key Tables are more sensitive
While both table types have version limits, Primary Key tables are "choked" more easily for three reasons:
1. Write Amplification: For every row, StarRocks must look up the PK index and potentially update a Delete Vector. This consumes more CPU and I/O than a Duplicate Key append.
2. Compaction Overhead: Primary Key compaction is more resource-intensive because it must merge data and reconcile Delete Vectors. Because it takes longer to compact, the "Compaction Score" or "Version Count" stays high for longer.
3. Index Weights: In shared-data clusters, the Primary Key index itself contributes to the compaction score (controlled by pk_index_compaction_score_ratio). This means a PK table reaches the "slowdown" threshold faster than a Duplicate Key table with the same number of data files.
Summary of Documentation Links
* *Primary Key Table Best Practices*: Details the slowdown thresholds and how to monitor them using show proc '/transactions/...'.
* *Compaction for Shared-data*: Explains the calculation of the Compaction Score and the lake_ingest_slowdown_threshold.
* *BE Configuration*: Defines parameters like tablet_max_versions and pk_index_compaction_score_ratio.
In short: Duplicate Key tables are "harder to choke" because they perform the bare minimum work (append only), allowing compaction to keep up with much higher ingestion frequencies before hitting the safety limits are triggered.
References
• best_practices/primarykey_table.md
• administration/management/compaction.md
• administration/management/BE_configuration.md
References
• best_practices/primarykey_table.md
• administration/management/compaction.mdRocky
07/03/2026, 5:25 PM