morrySnow commented on code in PR #12483: URL: https://github.com/apache/doris/pull/12483#discussion_r975966586
########## fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostCalculator.java: ########## @@ -106,19 +112,47 @@ public CostEstimate visitPhysicalLocalQuickSort( return new CostEstimate( childStatistics.computeSize(), statistics.computeSize(), - childStatistics.computeSize()); + 0); } @Override public CostEstimate visitPhysicalDistribute( PhysicalDistribute<? extends Plan> distribute, PlanContext context) { - StatsDeriveResult statistics = context.getStatisticsWithCheck(); StatsDeriveResult childStatistics = context.getChildStatistics(0); + DistributionSpec spec = distribute.getDistributionSpec(); + // shuffle + if (spec instanceof DistributionSpecHash) { + return new CostEstimate( + childStatistics.computeSize(), + 0, + childStatistics.computeSize()); + } + // replicate + if (spec instanceof DistributionSpecReplicated) { + int beNumber = ConnectContext.get().getEnv().getClusterInfo().getBackendIds(true).size(); + int instanceNumber = ConnectContext.get().getSessionVariable().getParallelExecInstanceNum(); + beNumber = Math.max(1, beNumber); + + return new CostEstimate( + childStatistics.computeSize() * beNumber, Review Comment: This PR aim to get a correct plan of colocate join and bucket shuffle join. Good cost model is not including. We need to adjust it finely after this PR and #12767 ########## fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostCalculator.java: ########## @@ -158,22 +192,10 @@ public CostEstimate visitPhysicalNestedLoopJoin( StatsDeriveResult leftStatistics = context.getChildStatistics(0); StatsDeriveResult rightStatistics = context.getChildStatistics(1); - List<Id> leftIds = context.getChildOutputIds(0); - List<Id> rightIds = context.getChildOutputIds(1); - - // TODO: handle some case - // handle cross join, onClause is empty ..... - if (nestedLoopJoin.getJoinType().isCrossJoin()) { - return new CostEstimate( - leftStatistics.computeColumnSize(leftIds) + rightStatistics.computeColumnSize(rightIds), - rightStatistics.computeColumnSize(rightIds), - 0); - } - // TODO: network 0? return new CostEstimate( - (leftStatistics.computeColumnSize(leftIds) + rightStatistics.computeColumnSize(rightIds)) / 2, - rightStatistics.computeColumnSize(rightIds), + leftStatistics.computeSize() * rightStatistics.computeSize(), + rightStatistics.computeSize(), Review Comment: This PR aim to get a correct plan of colocate join and bucket shuffle join. Good cost model is not including. We need to adjust it finely after this PR and https://github.com/apache/doris/pull/12767 -- 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