[Improvement](statistics)Add config for the threshold of column count for auto analyze (#27713)
This commit is contained in:
@ -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";
|
||||
@ -1315,6 +1317,13 @@ public class SessionVariable implements Serializable, Writable {
|
||||
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."},
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -181,9 +181,13 @@ public class StatisticsAutoCollector extends StatisticsCollector {
|
||||
protected AnalysisInfo getReAnalyzeRequiredPart(AnalysisInfo jobInfo) {
|
||||
TableIf table = StatisticsUtil
|
||||
.findTable(jobInfo.catalogId, jobInfo.dbId, jobInfo.tblId);
|
||||
// Skip tables that are too width.
|
||||
if (table.getBaseSchema().size() > StatisticsUtil.getAutoAnalyzeTableWidthThreshold()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AnalysisManager analysisManager = Env.getServingEnv().getAnalysisManager();
|
||||
TableStatsMeta tblStats = analysisManager.findTableStatsStatus(table.getId());
|
||||
|
||||
if (!table.needReAnalyzeTable(tblStats)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -939,6 +939,16 @@ public class StatisticsUtil {
|
||||
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;
|
||||
}
|
||||
|
||||
public static String encodeValue(ResultRow row, int index) {
|
||||
if (row == null || row.getValues().size() <= index) {
|
||||
return "NULL";
|
||||
|
||||
Reference in New Issue
Block a user