englefly commented on code in PR #17916:
URL: https://github.com/apache/doris/pull/17916#discussion_r1141245299


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/stats/JoinEstimation.java:
##########
@@ -39,9 +39,9 @@ private static Statistics estimateInnerJoin(Statistics 
crossJoinStats, List<Expr
                 .sorted((a, b) -> {
                     double sub = a.second - b.second;
                     if (sub > 0) {
-                        return -1;
-                    } else if (sub < 0) {
                         return 1;
+                    } else if (sub < 0) {
+                        return -1;

Review Comment:
   because this formula
   ```
   for (int i = 0; i < sortedJoinConditions.size(); i++) {
               sel *= Math.pow(sortedJoinConditions.get(i).second, 1 / 
Math.pow(2, i));
   }
   ```
   sel=sel0 * sel1^(1/2) * ...
   if sel0 > sel1, we have sel>sel0, but sel>sel1 is not always hold.
   
   suppose we have filter `(a=b) and (c=d)`
   sel1: selectivity of (a=b), sel1=0.5
   sel2: selectivity of (c=d), sel2=0.04
   
   sel= 0.5 * 0.2 = 0.25
   then sel > sel2. this is wrong
   
   
   
   



-- 
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

Reply via email to