ABor
04/22/2026, 5:50 PMRocky
04/22/2026, 5:51 PMALTER TABLE.
2) Does range distribution work with partitioning?
Yes, range distribution works seamlessly with partitioning. It is not restricted to a single partition.
StarRocks maintains its two-level data distribution strategy:
1. First Level (Partitioning): You can use Expression, Range, or List partitioning (e.g., partitioning by event_date). This splits the table into high-level management units.
2. Second Level (Bucketing/Distribution): Within each partition, data is distributed into tablets. While traditional tables use Hash or Random bucketing at this level, range-based distribution allows the data within that specific partition to be distributed based on the range of the key columns (typically the ORDER BY or DUPLICATE KEY columns).
Key details of this behavior:
* Multi-partition support: You can have a table partitioned by day, and within each day's partition, the tablets will be automatically managed via range distribution.
* Automatic Management: If a specific day's partition receives a massive influx of data (a hotspot), StarRocks will automatically split the tablets in that specific partition to maintain optimal performance and balance.
* Syntax: If enable_range_distribution is enabled (in v4.1+), you can create such a table by specifying an ORDER BY clause (for Duplicate Key tables) without a DISTRIBUTED BY clause.
Summary Comparison:
Feature | Hash/Random Bucketing | Range-based Distribution
Cluster Type | Shared-nothing & Shared-data | Shared-data Only
Tablet Count | Fixed (or manual change) | Automatic (Dynamic)
Partitioning | Supported | Supported
Data Skew | Handled via good key selection | Automatically mitigated
Automatically mitigated via splitting** |
References
• table_design/data_distribution/Data_distribution.md
• table_design/data_distribution/feature-support-data-distribution.md
• deployment/shared_data/feature-support-shared-data.md
• table_design/data_distribution/dynamic_partitioning.mdABor
04/24/2026, 7:53 AMRocky
04/24/2026, 7:53 AMDISTRIBUTED BY RANDOM for Duplicate Key tables to ensure data is evenly spread regardless of key distribution.
* Automatic Bucket Number (v2.5.7+): Let StarRocks automatically determine the initial bucket count based on your cluster size and disk count.
* Manual Adjustment: Use ALTER TABLE ... MODIFY SET ("bucket_num" = "XX") if you find that a table's distribution is no longer optimal.
Summary:
While the "Virtual Buckets" infrastructure (#59134) is being built to make data distribution more flexible across the board, the automatic, range-based dynamic management remains a flagship feature of the Shared-data architecture to leverage the benefits of storage-compute separation.
References
• table_design/data_distribution/Data_distribution.md
• deployment/shared_data/feature-support-shared-data.md
• table_design/data_distribution/feature-support-data-distribution.md
• quick_start/shared-data.mdABor
04/24/2026, 7:55 AMRocky
04/24/2026, 7:56 AMuser_id from 1000 to 2000).
* Physical Layer: Data is stored in immutable Segments (S3 objects). A single segment might contain keys ranging from 1000 to 2000.
2. How the "Split" Occurs (Metadata Change)
When a tablet becomes a hotspot or oversized and needs to split:
1. FE Metadata Update: The Frontend (FE) identifies the split point (e.g., 1500).
2. Creation of New Tablets: Two new tablets are registered in the metadata.
* Tablet A: Range [1000, 1500)
* Tablet B: Range [1500, 2000]
3. Referencing Existing Rowsets: Both Tablet A and Tablet B are updated to point to the exact same Rowset and Segment IDs that the parent tablet used. No data is copied.
3. Internal Code Logic: "Skipping Deletion" and "Shared Files"
To prevent S3 objects from being deleted while they are still referenced by the new "split" tablets, StarRocks introduced logic to mark files as shared.
* PR #71135 (and related #70685) explicitly implements a fix to skip data file deletion for range distribution tablets.
* In the lake (Shared-data) storage engine, the TabletMetadata structure (defined in protos/lake_metadata.proto) tracks which data files belong to a tablet. When a split happens, the versioning mechanism ensures that the new metadata entries "inherit" the file references from the parent.
4. How Queries Work (The "Read-Time Split")
If the segments aren't split, how does a query on Tablet A avoid reading Tablet B's data?
* Segment Range Pruning: Each segment file in StarRocks contains internal metadata (min/max values for columns).
* Scan-Time Filtering: When a Compute Node (CN) scans Tablet A, the Scan operator is aware of the tablet's range boundaries ([1000, 1500)). As it reads the shared segment file, it applies these range predicates at the storage engine level to skip data blocks that fall outside the current tablet's boundaries.
5. When does physical splitting actually happen?
The data is eventually "physically" reorganized during Compaction.
* When the background compaction process runs for Tablet A, it will read the shared segments, filter out the data that no longer belongs to its range (>1500), and write a new, smaller segment containing only the relevant data.
* The old, large shared segment remains in S3 until all tablets referencing it (A and B) have undergone compaction and no longer need it. At that point, the StarRocks Vacuum process (Garbage Collector) deletes the original file from S3.
Summary for your curiosity:
* Shared-nothing: Splitting = Physical data movement + rewriting (High cost).
* Shared-data: Splitting = Metadata pointer creation + Scan-time filtering (Near-zero cost).
* The "Secret Sauce": The lake engine's ability to have multiple tablets reference the same physical S3 objects via versioned metadata.
Relevant Code Areas in GitHub:
* `fe/fe-core/src/main/java/com/starrocks/clone/TabletScheduler.java`: Logic for deciding when to split.
* `be/src/storage/lake/`: The implementation of the Shared-data storage engine.
* `protos/lake_metadata.proto`: Definition of how tablets map to files and ranges to files are tracked.
References
• faq/shared_data_faq.mdRocky
04/24/2026, 7:56 AM