Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Automatically specifying tablet when create table #10614

Merged
merged 4 commits into from
Sep 15, 2022

Conversation

chaoyli
Copy link
Contributor

@chaoyli chaoyli commented Aug 30, 2022

What type of PR is this:

  • bugfix
  • feature
  • enhancement
  • refactor
  • others

Which issues of this PR fixes :

Fixes #
Specifying the tablet num when creating a table is frustrating.
Many users can not know how to give the right hint.
The pull request tries to eliminate the pain by automatically specifying the num.

  1. If the table is created from scratch, the tablet num will be
    speculated according to the number of backends.

    CREATE TABLE `test_table2` (
        `pk1` bigint(20) NOT NULL COMMENT "",
        `pk2` date NOT NULL COMMENT "",
        `v0` varchar(65533) NOT NULL COMMENT ""
    ) ENGINE=OLAP
    PRIMARY KEY(`pk1`, `pk2`)
    DISTRIBUTED BY HASH(`pk1`)
    
     if (backendNum <= 3) {
        bucketNum = 2 * backendNum;
     } else if (backendNum <= 6) {
        bucketNum = (int) 1.5 * backendNum;
     } else if (backendNum <= 12) {
        bucketNum = 12;
     }  else {
        bucketNum = Math.min(backendNum, 48);
     }
    
  2. Add partition will use the last five partition sizes to calculate the tablet num.

    ALTER TABLE test_table2 add partition p20220811 values less than("2022-08-11")
    

    The num = total_size_of_last_five_partition / 1GB

Problem Summary(Required) :

Checklist:

  • I have added test cases for my bug fix or my new feature
  • I have added user document for my new feature or new function

@chaoyli chaoyli force-pushed the main branch 3 times, most recently from fc4f7ae to 8317546 Compare August 30, 2022 13:49
@chaoyli chaoyli changed the title [Feature] Automatically create tablet when create table [Feature] Automatically specifying tablet when create table Aug 30, 2022
// The bucketNum will be given a small multiplier factor for small backends.
if (backendNum <= recentPartitionNum) {
avgBucketNum = 2 * backendNum;
} else if (backendNum <= 6) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.5x and 1.2x may cause very unbalanced load between BEs when PoC testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PoC will only have the same backends. So I think the bucket is enough. And also the PoC backend will not be installed many nodes

trueeyu
trueeyu previously approved these changes Sep 9, 2022
trueeyu
trueeyu previously approved these changes Sep 9, 2022
@chaoyli
Copy link
Contributor Author

chaoyli commented Sep 9, 2022

run starrocks_fe_unittest

Specfiy the tablet num when create table is very noisy.
Many users can not know how to give a right hint.
The pull request try to eliminate the pain to specify the num.

1. If the table is created from scratch, the tablet num will be
equal to the number of backends.
```
CREATE TABLE `test_table2` (
    `pk1` bigint(20) NOT NULL COMMENT "",
    `pk2` date NOT NULL COMMENT "",
    `v0` varchar(65533) NOT NULL COMMENT ""
) ENGINE=OLAP
PRIMARY KEY(`pk1`, `pk2`)
DISTRIBUTED BY HASH(`pk1`)
```

2. Add partition will use the last five partition size to calculate the tablet num.
```
ALTER TABLE test_table2 add partition p20220811 values less than("2022-08-11")
```
The num = total_size_of_last_five_partition / 10GB
@sonarcloud
Copy link

sonarcloud bot commented Sep 15, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@wanpengfei-git
Copy link
Collaborator

[FE PR Coverage Check]

😞 fail : 24 / 51 (47.06%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/catalog/OlapTable.java 0 4 00.00% [889, 890, 893, 896]
🔵 com/starrocks/catalog/RandomDistributionInfo.java 0 2 00.00% [62, 63]
🔵 com/starrocks/catalog/DistributionInfo.java 0 1 00.00% [71]
🔵 com/starrocks/server/LocalMetastore.java 19 39 48.72% [949, 953, 967, 968, 969, 970, 971, 973, 975, 976, 977, 981, 982, 983, 984, 986, 987, 988, 990, 1017]
🔵 com/starrocks/sql/parser/AstBuilder.java 1 1 100.00% []
🔵 com/starrocks/analysis/HashDistributionDesc.java 1 1 100.00% []
🔵 com/starrocks/catalog/HashDistributionInfo.java 3 3 100.00% []

@wanpengfei-git wanpengfei-git added the Approved Ready to merge label Sep 15, 2022
@wanpengfei-git
Copy link
Collaborator

run starrocks_admit_test

@chaoyli chaoyli enabled auto-merge (squash) September 15, 2022 05:57
@chaoyli chaoyli merged commit 8c19e6b into StarRocks:main Sep 15, 2022
@nshangyiming
Copy link
Contributor

Shall we update the corresponding documentation?

Astralidea pushed a commit that referenced this pull request Sep 19, 2022
…et num (#11337)

In this PR [Feature] Automatically specifying tablet when create table #10614, SR set default bucket num from 10 to 0, this would result in create mv failed when user not set bucket num. according to that PR, we use be numner to calculate bucket num
SR do not support create mv on view, so we need to disable it at analyze stage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants