You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "englefly (via GitHub)" <gi...@apache.org> on 2023/03/19 03:30:44 UTC

[GitHub] [doris] englefly commented on a diff in pull request #17916: [improve](nereids)adjust distribution stats derive and fix bug in join estimation

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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org