xzj7019 commented on code in PR #40654:
URL: https://github.com/apache/doris/pull/40654#discussion_r1753891100


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/stats/JoinEstimation.java:
##########
@@ -177,14 +181,27 @@ private static double 
computeSelectivityForBuildSideWhenColStatsUnknown(Statisti
             if (cond instanceof EqualTo) {
                 EqualTo equal = (EqualTo) cond;
                 if (equal.left() instanceof Slot && equal.right() instanceof 
Slot) {
-                    ColumnStatistic buildColStats = 
buildStats.findColumnStatistics(equal.left());
-                    if (buildColStats == null) {
-                        buildColStats = 
buildStats.findColumnStatistics(equal.right());
+                    Slot buildSideSlot = null;
+                    if (buildStats.findColumnStatistics(equal.left()) != null) 
{
+                        buildSideSlot = (Slot) equal.left();
+                    } else if (buildStats.findColumnStatistics(equal.right()) 
!= null) {
+                        buildSideSlot = (Slot) equal.right();
                     }
-                    if (buildColStats != null) {
-                        double buildSel = Math.min(buildStats.getRowCount() / 
buildColStats.count, 1.0);
-                        buildSel = Math.max(buildSel, 
UNKNOWN_COL_STATS_FILTER_SEL_LOWER_BOUND);
-                        sel = Math.min(sel, buildSel);
+                    // the processing is mainly for olap table since external 
table rarely has column level statistics
+                    if (buildSideSlot instanceof SlotReference
+                            && ((SlotReference) 
buildSideSlot).getTable().isPresent()
+                            && (((SlotReference) 
buildSideSlot).getTable().get() instanceof OlapTable)) {
+                        OlapTable olapTable = (OlapTable) ((SlotReference) 
buildSideSlot).getTable().get();
+                        TableStatsMeta tableStatsMeta = 
Env.getCurrentEnv().getAnalysisManager()
+                                .findTableStatsStatus(olapTable.getId());
+                        if (tableStatsMeta != null) {
+                            double tableRowCount = 
tableStatsMeta.getRowCount(olapTable.getBaseIndexId());

Review Comment:
   1, 3: yes but seems no other way to do if we will remove the count usage. I 
will do a next pr to split no-stats and stats-available path to allow count 's 
usage in no-stats cases.
   2: I will move total handling logic from row count acquirement.



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