From 18c44bd58961e50b6859e22a68ed755c7a1e4391 Mon Sep 17 00:00:00 2001 From: zeekling Date: Sat, 28 Jan 2023 23:57:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E4=B9=A0FLinkSQl=E8=B0=83=E4=BC=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 调优/flinkSql.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/调优/flinkSql.md b/调优/flinkSql.md index dd08950..e6807d2 100644 --- a/调优/flinkSql.md +++ b/调优/flinkSql.md @@ -86,3 +86,25 @@ LocalGlobal 如何解决数据倾斜的问题。 段聚合 、 ONE_PHASE( 仅使用 Global 一阶段聚合)。 +```java +// 初始化运行环境 +StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); +TableEnvironment tEnv = StreamTableEnvironment.create(env); +Configuration configuration = tEnv.getConfig().getConfiguration(); +// 开启 miniBatch +configuration.setString("table.exec.mini-batch.enabled ", true); +// 批量输出的间隔时间 +configuration.setString("table.exec.mini-batch.allow latency ", "5s"); +// 防止 OOM 设置每个批次最多缓存数据的条数 ,可以设为 2 万条 +configuration.setString("table.exec.mini-batch.size ", "20000"); +// 开启 LocalGlobal +config uration.setString("table.optimizer.agg-phase-strategy", "TWO_PHASE"); +``` + +- 1) 需要先开启 MiniBatch。 +- 2) 开启 LocalGlobal 需要 UDAF 实现 Merge 方法 。 + +# 开启Split Distinct + + +