[Doc] Document session variables and update Flat_json.md (backport #62367) (#62399)

Co-authored-by: Murphy <96611012+murphyatwork@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
mergify[bot] 2025-08-28 14:01:15 +08:00 committed by GitHub
parent dc9598f87f
commit 02e81c8b8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 72 additions and 0 deletions

View File

@ -217,6 +217,18 @@ Used for MySQL client compatibility. No practical usage.
* **Data type**: String
* **Introduced in**: v2.5.14
### cbo_json_v2_dict_opt
* **Description**: Whether to enable low-cardinality dictionary optimization for Flat JSON (JSON v2) extended string subcolumns created by JSON path rewrite. When enabled, the optimizer may build and use global dictionaries for those subcolumns to accelerate string expressions, GROUP BY, and JOIN operations.
* **Default**: true
* **Data type**: Boolean
### cbo_json_v2_rewrite
* **Description**: Whether to enable JSON v2 path rewrite in the optimizer. When enabled, JSON functions (such as `get_json_*`) can be rewritten to direct access of Flat JSON subcolumns, enabling predicate pushdown, column pruning, and dictionary optimization.
* **Default**: true
* **Data type**: Boolean
### cbo_materialized_view_rewrite_related_mvs_limit
* **Description**: Specifies the maximum number of candidate materialized views allowed during query planning.

View File

@ -203,6 +203,18 @@ Setting Flat JSON-related properties on table level is supported from v4.0 onwar
2. Enable FE pruning feature: `SET GLOBAL cbo_prune_json_subfield = true;`
## Related session variables
- `cbo_json_v2_rewrite` (default: true): Enables JSON v2 path rewrite so that expressions like `get_json_*` can be rewritten to direct access of Flat JSON subcolumns, unlocking predicate pushdown and column pruning.
- `cbo_json_v2_dict_opt` (default: true): Enables low-cardinality dictionary optimization for Flat JSON extended string subcolumns produced by the rewrite, which can speed up string expressions, GROUP BY, and JOIN.
Example:
```SQL
SET cbo_json_v2_rewrite = true;
SET cbo_json_v2_dict_opt = true;
```
## Enabling Flat JSON Feature (Before Version 3.4)
1. Modify BE configuration: `enable_json_flat`, which defaults to `false` before version 3.4. For modification methods, refer to

View File

@ -216,6 +216,18 @@ MySQL クライアント互換性のために使用されます。実際の用
* **データ型**: 文字列
* **導入バージョン**: v2.5.14
### cbo_json_v2_dict_opt
* **説明**: JSON v2 のパス書き換えで生成される Flat JSON の文字列サブカラムに対して、低カーディナリティ辞書最適化を有効にするかどうか。有効にすると、オプティマイザはそれらのサブカラムにグローバル辞書を構築・利用し、文字列式、GROUP BY、JOIN などを高速化できます。
* **デフォルト**: true
* **データ型**: Boolean
### cbo_json_v2_rewrite
* **説明**: オプティマイザで JSON v2 のパス書き換えを有効にするかどうか。有効にすると、JSON 関数(`get_json_*` など)を Flat JSON のサブカラムへの直接アクセスに書き換え、述語プッシュダウン、カラムプルーニング、辞書最適化を有効化します。
* **デフォルト**: true
* **データ型**: Boolean
### cbo_materialized_view_rewrite_related_mvs_limit
* **説明**: クエリプランニング中に許可される候補マテリアライズドビューの最大数を指定します。

View File

@ -203,6 +203,18 @@ StarRocks 共有なしクラスタは v3.3.0 から Flat JSON をサポートし
2. FE プルーニング機能を有効化します:`SET GLOBAL cbo_prune_json_subfield = true;`
## 関連するセッション変数
- `cbo_json_v2_rewrite`(デフォルト: true: JSON v2 のパス書き換えを有効化し、`get_json_*` などの関数を Flat JSON のサブカラムへの直接アクセスに書き換えて、述語プッシュダウンやカラムプルーニングを有効にします。
- `cbo_json_v2_dict_opt`(デフォルト: true: パス書き換えで生成された Flat JSON の文字列サブカラムに対して、低カーディナリティ辞書最適化を有効にし、文字列式、GROUP BY、JOIN の高速化に寄与します。
例:
```SQL
SET cbo_json_v2_rewrite = true;
SET cbo_json_v2_dict_opt = true;
```
## Flat JSON 機能の有効化(バージョン 3.4 以前)
1. BE 設定を変更します:`enable_json_flat` はバージョン 3.4 以前はデフォルトで `false` です。変更方法については、[Configure BE parameters](../administration/management/BE_configuration.md#configure-be-parameters) を参照してください。

View File

@ -215,6 +215,18 @@ ALTER USER 'jack' SET PROPERTIES ('session.query_timeout' = '600');
* 类型String
* 引入版本v2.5.14
### cbo_json_v2_dict_opt
* 描述:是否为 JSON v2 路径改写生成的 Flat JSON 字符串子列启用低基数字典优化。开启后优化器可以为这些子列构建并使用全局字典从而加速字符串表达式、GROUP BY、JOIN 等操作。
* 默认值true
* 类型Boolean
### cbo_json_v2_rewrite
* 描述:是否在优化器中启用 JSON v2 路径改写。开启后,会将 JSON 函数(如 `get_json_*`)改写为直接访问 Flat JSON 子列,从而启用谓词下推、列裁剪以及字典优化。
* 默认值true
* 类型Boolean
### cbo_materialized_view_rewrite_related_mvs_limit
* 描述:用于指定查询在 Plan 阶段最多拥有的候选物化视图个数。

View File

@ -203,6 +203,18 @@ StarRocks存算一体集群从v3.3.0开始支持Flat JSON存算分离集群
2. 启用FE分区裁剪功能`SET GLOBAL cbo_prune_json_subfield = true;`
## 相关会话变量
- `cbo_json_v2_rewrite`默认true启用 JSON v2 路径改写,将 `get_json_*` 等函数改写为直接访问 Flat JSON 子列,从而启用谓词下推和列裁剪。
- `cbo_json_v2_dict_opt`默认true为路径改写生成的 Flat JSON 字符串子列启用低基数字典优化可加速字符串表达式、GROUP BY 和 JOIN。
示例:
```SQL
SET cbo_json_v2_rewrite = true;
SET cbo_json_v2_dict_opt = true;
```
## 启用Flat JSON功能3.4版本之前)
1. 修改BE配置`enable_json_flat`在3.4版本之前默认为`false`。修改方法参考