YBAインスタンスへのログイン

kubectl config set-context <CONTEXT_NAME> --kubeconfig <UNIVERSE_CONFIG_FILE>
kubectl exec -it <POD_NAME> -n <NAMESPACE> -c yugaware -- bash

Node(Pod)へのログイン(ssh)

YSQLSHの起動

パラメータ(gflag)の確認

enable_automatic_tablet_splitting

1. --ysql_num_shards_per_tserver-1の場合

2. --ysql_num_shards_per_tserver-1ではない場合

テーブルの作成

ハッシュシャーディング

create table t1 ( id int, name text, primary key(id));

レンジシャーディング

create table t2 ( id int, name text, primary key(id ASC));

データの投入

insert into t1 (id, name) select i, left(md5(random()::text),4) from generate_series(1,20000000) i;
insert into t2 (id, name) select i, left(md5(random()::text),4) from generate_series(1,20000000) i;

データの確認

さらに追加

insert into t1 (id, name) select i, left(md5(random()::text),4) from generate_series(20000001,40000000) i;
insert into t2 (id, name) select i, left(md5(random()::text),4) from generate_series(20000001,40000000) i;

パラメータ(gflag)の確認

--ysql_num_shards_per_tserver-1の場合

--ysql_num_shards_per_tserver-1ではない場合

CREATE TABLE hashdemo (
    id int ,
    name text
    PRIMARY KEY (id HASH)
) SPLIT INTO 16 TABLETS;
ycqlsh:example> CREATE TABLE tracking (id int PRIMARY KEY) WITH tablets = 10;
CREATE TABLE rangedemo(
  a int,
  b int,
  primary key(a asc, b desc)
) SPLIT AT VALUES((100), (200), (200, 5));

YugabyteDB Docs: Tablet Splitting