Skip to content

Commit

Permalink
[Enhancement] Make default bucket num at least 16 when table is unpar…
Browse files Browse the repository at this point in the history
…titioned (#47005)

Signed-off-by: meegoo <meegoo.sr@gmail.com>
  • Loading branch information
meegoo authored Jun 17, 2024
1 parent 076c207 commit 2176e83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ public static int calAvgBucketNumOfRecentPartitions(OlapTable olapTable, int rec
int bucketNum = 0;
if (olapTable.getPartitions().size() < recentPartitionNum || !enableAutoTabletDistribution) {
bucketNum = CatalogUtils.calBucketNumAccordingToBackends();
// If table is not partitioned, the bucketNum should be at least DEFAULT_UNPARTITIONED_TABLE_BUCKET_NUM
if (!olapTable.getPartitionInfo().isPartitioned()) {
bucketNum = bucketNum > FeConstants.DEFAULT_UNPARTITIONED_TABLE_BUCKET_NUM ?
bucketNum : FeConstants.DEFAULT_UNPARTITIONED_TABLE_BUCKET_NUM;
}
return bucketNum;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public class FeConstants {
// Max counter num of TOP K function
public static final int MAX_COUNTER_NUM_OF_TOP_K = 100000;

public static final int DEFAULT_UNPARTITIONED_TABLE_BUCKET_NUM = 16;

public static final String DOCUMENT_SHOW_ALTER =
"https://docs.starrocks.io/docs/sql-reference/sql-statements/data-manipulation/SHOW_ALTER";
public static final String DOCUMENT_SHOW_ALTER_MATERIALIZED_VIEW =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.starrocks.catalog.OlapTable;
import com.starrocks.catalog.Partition;
import com.starrocks.common.Config;
import com.starrocks.common.FeConstants;
import com.starrocks.common.util.concurrent.lock.LockType;
import com.starrocks.common.util.concurrent.lock.Locker;
import com.starrocks.pseudocluster.PseudoCluster;
Expand Down Expand Up @@ -90,8 +91,8 @@ public void testCTASAutoTablet() throws Exception {
} finally {
locker.unLockDatabase(db, LockType.READ);
}
Assert.assertEquals(bucketNum1, 6);
Assert.assertEquals(bucketNum1, FeConstants.DEFAULT_UNPARTITIONED_TABLE_BUCKET_NUM);
Assert.assertEquals(bucketNum2, 3);
Assert.assertEquals(bucketNum3, 6);
Assert.assertEquals(bucketNum3, FeConstants.DEFAULT_UNPARTITIONED_TABLE_BUCKET_NUM);
}
}

0 comments on commit 2176e83

Please sign in to comment.