Skip to content

Commit

Permalink
chore(docs): add sharding docs (#334)
Browse files Browse the repository at this point in the history
* chore(sharding): add avg meta data

Signed-off-by: wbtlb <[email protected]>

* chore(docs): add sharding docs

Signed-off-by: wbtlb <[email protected]>

* chore(docs): add sharding docs

Signed-off-by: wbtlb <[email protected]>

Signed-off-by: wbtlb <[email protected]>
Co-authored-by: wbtlb <[email protected]>
  • Loading branch information
wbtlb and wbtlb authored Sep 26, 2022
1 parent 60013c4 commit 33f09a3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/docs/Features/sharding.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ SELECT order_id FROM order.t_order WHERE order_id = 1;
```
SELECT order_id FROM order.t_order_00001 WHERE order_id = 1;
```

**特别说明: SQL rewrite 在修改标识符计算实际表名时会自动根据分片规则添加表索引,索引规则位 表名_索引,索引位为5位表示。例如:`t_order` 表改写后为 `t_order_00000`。因此用户需要根据实际业务场景先创建好对应的表名**

#### 2. 补列
需要在查询语句中补列通常由两种情况导致。 第一种情况是 Pisa-Proxy 需要在结果归并时获取相应数据,但该数据并未能通过查询的SQL返回。 这种情况主要是针对 GROUP BY 和 ORDER BY。结果归并时,需要根据 GROUP BY 和 ORDER BY 的字段项进行分组和排序,但如果原始SQL的选择项中若并未包含分组项或排序项,则需要对原始SQL进行改写。
例如有以下 SQL 语句:
Expand Down Expand Up @@ -65,6 +68,7 @@ SELECT COUNT(price) AS AVG_DERIVED_COUNT_00000, SUM(price) AS AVG_DERIVED_SUM_00
- 基于单 shard-key 的静态分片规则
- 分片算法:crc32mod 和 mod
- 单库水平分表
- 基于分片的查询,更新,删除,修改

#### 使用限制
- 不支持子查询
Expand All @@ -82,6 +86,4 @@ SELECT COUNT(price) AS AVG_DERIVED_COUNT_00000, SUM(price) AS AVG_DERIVED_SUM_00
|broadcast_tables|Vec\<String\>|||暂不支持||
|table_sharding_algorithm_name|enum|||分片算法|
|table_sharding_column|String|||分片键|
|sharding_count|u64|||分片数|


|sharding_count|u64|||分片数|
22 changes: 22 additions & 0 deletions docs/docs/UseCases/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,28 @@ spec:
db: "socksdb"
```
- DataShard
```yaml
apiVersion: core.database-mesh.io/v1alpha1
kind: DataShard
metadata:
name: catalogue
namespace: demotest
labels:
source: catalogue
spec:
rules:
- tableName: "t_order"
tableStrategy:
tableShardingAlgorithmName: "mod"
tableShardingColumn: "id"
shardingCount: 4
actualDatanodes:
valueSource:
nodes:
- value: "ds001"
```
#### 应用访问数据库切换至 Pisanix
Expand Down

0 comments on commit 33f09a3

Please sign in to comment.