Skip to content

Commit

Permalink
change switch
Browse files Browse the repository at this point in the history
Signed-off-by: Murphy <[email protected]>
  • Loading branch information
murphyatwork committed Dec 16, 2024
1 parent 327a80a commit 77dc447
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
8 changes: 2 additions & 6 deletions fe/fe-core/src/main/java/com/starrocks/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -2148,12 +2148,8 @@ public class Config extends ConfigBase {
@ConfField(mutable = true)
public static long histogram_max_sample_row_count = 10000000;

@ConfField(mutable = true, comment = "Use table sample instead of row-level bernoulli sample to collect histogram")
public static boolean histogram_enable_table_sample = true;

@ConfField(mutable = true,
comment = "Use table sample instead of row-level bernoulli sample to collect column stats")
public static boolean enable_column_stats_use_table_sample = true;
@ConfField(mutable = true, comment = "Use table sample instead of row-level bernoulli sample to collect statistics")
public static boolean enable_use_table_sample_collect_statistics = true;

@ConfField(mutable = true)
public static long connector_table_query_trigger_analyze_small_table_rows = 10000000; // 10M
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private String buildCollectHistogram(Database database, Table table, double samp
context.put("totalRows", Config.histogram_max_sample_row_count);

// TODO: use it by default and remove this switch
if (Config.histogram_enable_table_sample && sampleRatio > 0.0 && sampleRatio < 1.0) {
if (Config.enable_use_table_sample_collect_statistics && sampleRatio > 0.0 && sampleRatio < 1.0) {
String sampleClause = String.format("SAMPLE('percent'='%d')", (int) (sampleRatio * 100));
context.put("sampleClause", sampleClause);
context.put("randFilter", "TRUE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private static String generateRatioTable(String table, long limit,

String tabletHint =
tablets.stream().map(t -> String.valueOf(t.getTabletId())).collect(Collectors.joining(", "));
if (!Config.enable_column_stats_use_table_sample) {
if (!Config.enable_use_table_sample_collect_statistics) {
return String.format(" SELECT * FROM (SELECT * " +
" FROM %s tablet(%s) " +
" WHERE rand() <= %f " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private String generateTabletHint(List<TabletStats> tabletStats, double readRati
.map(e -> String.valueOf(e.getTabletId()))
.collect(Collectors.joining(", ", "(", ")")));

if (Config.enable_column_stats_use_table_sample) {
if (Config.enable_use_table_sample_collect_statistics) {
int percent = Math.max(1, Math.min(100, (int) (readRatio * 100)));
hint.append(String.format(" SAMPLE('percent'='%d') LIMIT %d ", percent, sampleRowsLimit));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public void testAnalyzeHistogram() {
db, olapTable, Lists.newArrayList("v2"), Lists.newArrayList(Type.BIGINT),
StatsConstants.ScheduleType.ONCE, properties);

Config.histogram_enable_table_sample = false;
Config.enable_use_table_sample_collect_statistics = false;
Function<String, String> normalize = str -> str.replaceAll(" +", " ").toLowerCase();
String sql = Deencapsulation.invoke(histogramStatisticsCollectJob, "buildCollectHistogram",
db, olapTable, 0.1, 64L, Maps.newHashMap(), "v2", Type.BIGINT);
Expand Down Expand Up @@ -467,7 +467,7 @@ public void testAnalyzeHistogram() {
"`v5` not in (\"1991-01-01 00:00:00\",\"0000-01-01 00:00:00\") ORDER BY `v5` LIMIT 10000000) t",
t0StatsTableId, dbid)), normalize.apply(sql));

Config.histogram_enable_table_sample = true;
Config.enable_use_table_sample_collect_statistics = true;
sql = Deencapsulation.invoke(histogramStatisticsCollectJob, "buildCollectHistogram",
db, olapTable, 0.1, 64L, mostCommonValues, "v5", Type.DATETIME);
Assert.assertEquals(normalize.apply(String.format("INSERT INTO histogram_statistics SELECT %d, 'v5', %d, " +
Expand Down

0 comments on commit 77dc447

Please sign in to comment.