Skip to content

Commit

Permalink
Add config for the threshold of column count for auto analyze.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jibing-Li committed Nov 28, 2023
1 parent b48c40e commit 8ae679d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ public class SessionVariable implements Serializable, Writable {

public static final String ENABLE_AUTO_ANALYZE = "enable_auto_analyze";

public static final String AUTO_ANALYZE_TABLE_WIDTH_THRESHOLD = "auto_analyze_table_width_threshold";

public static final String FASTER_FLOAT_CONVERT = "faster_float_convert";

public static final String ENABLE_DECIMAL256 = "enable_decimal256";
Expand Down Expand Up @@ -1315,6 +1317,13 @@ public void setEnableLeftZigZag(boolean enableLeftZigZag) {
flag = VariableMgr.GLOBAL)
public boolean enableAutoAnalyze = true;

@VariableMgr.VarAttr(name = AUTO_ANALYZE_TABLE_WIDTH_THRESHOLD,
description = {"参与自动收集的最大表宽度,列数多于这个参数的表不参与自动收集",
"Maximum table width to enable auto analyze, "
+ "table with more columns than this value will not be auto analyzed."},
flag = VariableMgr.GLOBAL)
public int autoAnalyzeTableWidthThreshold = 70;

@VariableMgr.VarAttr(name = AUTO_ANALYZE_START_TIME, needForward = true, checker = "checkAnalyzeTimeFormat",
description = {"该参数定义自动ANALYZE例程的开始时间",
"This parameter defines the start time for the automatic ANALYZE routine."},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public class StatisticConstants {

public static final int SUBMIT_JOB_LIMIT = 5;

public static final int AUTO_ANALYZE_TABLE_WIDTH_THRESHOLD = 70;

static {
SYSTEM_DBS.add(SystemInfoService.DEFAULT_CLUSTER
+ ClusterNamespace.CLUSTER_DELIMITER + FeConstants.INTERNAL_DB_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ protected AnalysisInfo getReAnalyzeRequiredPart(AnalysisInfo jobInfo) {
AnalysisManager analysisManager = Env.getServingEnv().getAnalysisManager();
TableStatsMeta tblStats = analysisManager.findTableStatsStatus(table.getId());

// Skip tables that are too width.
if (table.getColumns().size() > StatisticsUtil.getAutoAnalyzeTableWidthThreshold()) {
return null;
}

if (!table.needReAnalyzeTable(tblStats)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -936,4 +936,14 @@ public static int getAnalyzeTimeout() {
return StatisticConstants.ANALYZE_TIMEOUT_IN_SEC;
}

public static int getAutoAnalyzeTableWidthThreshold() {
try {
return findConfigFromGlobalSessionVar(SessionVariable.AUTO_ANALYZE_TABLE_WIDTH_THRESHOLD)
.autoAnalyzeTableWidthThreshold;
} catch (Exception e) {
LOG.warn("Failed to get value of auto_analyze_table_width_threshold, return default", e);
}
return StatisticConstants.AUTO_ANALYZE_TABLE_WIDTH_THRESHOLD;
}

}

0 comments on commit 8ae679d

Please sign in to comment.