morrySnow commented on code in PR #35875: URL: https://github.com/apache/doris/pull/35875#discussion_r1635870616
########## fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java: ########## @@ -745,8 +747,32 @@ private ColumnStatistic getColumnStatistic(TableIf table, String colName, long i return ColumnStatistic.UNKNOWN; } } else { + if (!partitionNames.isEmpty()) { + PartitionColumnStatisticBuilder builder = new PartitionColumnStatisticBuilder(); + boolean isFirst = true; + boolean hasUnknown = false; + for (String partitionName : partitionNames) { + PartitionColumnStatistic pcolStats = Env.getCurrentEnv().getStatisticsCache() + .getPartitionColumnStatistics( + catalogId, dbId, table.getId(), idxId, partitionName, colName); + if (pcolStats.isUnKnown) { + hasUnknown = true; + break; + } + if (isFirst) { + builder = new PartitionColumnStatisticBuilder(pcolStats); + isFirst = false; + } else { + builder.merge(pcolStats); Review Comment: do merge after check all pcol stats is not unknown to avoid useless merge? ########## fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java: ########## @@ -764,19 +790,22 @@ private Statistics computeCatalogRelation(CatalogRelation catalogRelation) { Set<SlotReference> slotSet = slotSetBuilder.build(); Map<Expression, ColumnStatisticBuilder> columnStatisticBuilderMap = new HashMap<>(); TableIf table = catalogRelation.getTable(); - boolean isOlapTable = table instanceof OlapTable; AnalysisManager analysisManager = Env.getCurrentEnv().getAnalysisManager(); TableStatsMeta tableMeta = analysisManager.findTableStatsStatus(table.getId()); long tableUpdatedRows = tableMeta == null ? 0 : tableMeta.updatedRows.get(); - double rowCount = catalogRelation.getTable().getRowCountForNereids(); boolean hasUnknownKeyCol = false; long idxId = -1; + List<String> selectedPartitionNames = new ArrayList<>(); Review Comment: for better perf, use expected size list to avoid resize ########## fe/fe-core/src/main/java/org/apache/doris/statistics/PartitionColumnStatisticBuilder.java: ########## @@ -155,4 +155,25 @@ public PartitionColumnStatistic build() { dataSize, minValue, maxValue, minExpr, maxExpr, isUnknown, updatedTime); } + + public PartitionColumnStatisticBuilder merge(PartitionColumnStatistic other) { + count += other.count; Review Comment: ```suggestion count += other.count; ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org