This is an automated email from the ASF dual-hosted git repository.

lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 0fc5dde2477 [Exec](opt) opt the compound_pred preformance (#60137)
0fc5dde2477 is described below

commit 0fc5dde2477df0a389000a95c28ca2f74767a776
Author: HappenLee <[email protected]>
AuthorDate: Wed Jan 28 12:21:27 2026 +0800

    [Exec](opt) opt the compound_pred preformance (#60137)
    
    Before:
    ```
    SELECT    COUNT(ss_quantity),    COUNT(ss_wholesale_cost),    
COUNT(ss_list_price),    COUNT(ss_coupon_amt)  FROM store_sales  WHERE  
(ss_list_price >= 64.00 AND ss_list_price <= 74.00) OR (ss_coupon_amt >= 
5792.00 AND ss_coupon_amt <= 6792.00);
    
+--------------------+--------------------------+----------------------+----------------------+
    | COUNT(ss_quantity) | COUNT(ss_wholesale_cost) | COUNT(ss_list_price) | 
COUNT(ss_coupon_amt) |
    
+--------------------+--------------------------+----------------------+----------------------+
    |            1924148 |                  1924248 |              1969685 |    
          1925017 |
    
+--------------------+--------------------------+----------------------+----------------------+
    1 row in set (0.88 sec)
    ```
    
    After:
    ```
    SELECT    COUNT(ss_quantity),    COUNT(ss_wholesale_cost),    
COUNT(ss_list_price),    COUNT(ss_coupon_amt)  FROM store_sales  WHERE  
(ss_list_price >= 64.00 AND ss_list_price <= 74.00) OR (ss_coupon_amt >= 
5792.00 AND ss_coupon_amt <= 6792.00);
    
+--------------------+--------------------------+----------------------+----------------------+
    | COUNT(ss_quantity) | COUNT(ss_wholesale_cost) | COUNT(ss_list_price) | 
COUNT(ss_coupon_amt) |
    
+--------------------+--------------------------+----------------------+----------------------+
    |            1924148 |                  1924248 |              1969685 |    
          1925017 |
    
+--------------------+--------------------------+----------------------+----------------------+
    1 row in set (0.66 sec)
    ```
---
 be/src/vec/exprs/vcompound_pred.h | 67 ++++++++++++++++++++++++++-------------
 1 file changed, 45 insertions(+), 22 deletions(-)

diff --git a/be/src/vec/exprs/vcompound_pred.h 
b/be/src/vec/exprs/vcompound_pred.h
index c1ba88fa2af..c42ba60e9b9 100644
--- a/be/src/vec/exprs/vcompound_pred.h
+++ b/be/src/vec/exprs/vcompound_pred.h
@@ -239,15 +239,7 @@ public:
                 result_column = std::move(col_res);
             }
 
-            if constexpr (is_and_op) {
-                for (size_t i = 0; i < size; ++i) {
-                    lhs_data_column[i] &= rhs_data_column[i];
-                }
-            } else {
-                for (size_t i = 0; i < size; ++i) {
-                    lhs_data_column[i] |= rhs_data_column[i];
-                }
-            }
+            do_not_null_pred<is_and_op>(lhs_data_column, rhs_data_column, 
size);
         };
         auto vector_vector_null = [&]<bool is_and_op>() {
             auto col_res = ColumnUInt8::create(size);
@@ -264,19 +256,9 @@ public:
             auto* __restrict lhs_data_column_tmp = lhs_data_column;
             auto* __restrict rhs_data_column_tmp = rhs_data_column;
 
-            if constexpr (is_and_op) {
-                for (size_t i = 0; i < size; ++i) {
-                    res_nulls[i] = apply_and_null(lhs_data_column_tmp[i], 
lhs_null_map_tmp[i],
-                                                  rhs_data_column_tmp[i], 
rhs_null_map_tmp[i]);
-                    res_datas[i] = lhs_data_column_tmp[i] & 
rhs_data_column_tmp[i];
-                }
-            } else {
-                for (size_t i = 0; i < size; ++i) {
-                    res_nulls[i] = apply_or_null(lhs_data_column_tmp[i], 
lhs_null_map_tmp[i],
-                                                 rhs_data_column_tmp[i], 
rhs_null_map_tmp[i]);
-                    res_datas[i] = lhs_data_column_tmp[i] | 
rhs_data_column_tmp[i];
-                }
-            }
+            do_null_pred<is_and_op>(lhs_data_column_tmp, lhs_null_map_tmp, 
rhs_data_column_tmp,
+                                    rhs_null_map_tmp, res_datas, res_nulls, 
size);
+
             result_column = ColumnNullable::create(std::move(col_res), 
std::move(col_nulls));
         };
 
@@ -357,6 +339,47 @@ private:
         return (l_null & r_null) | (r_null & (r_null ^ a)) | (l_null & (l_null 
^ b));
     }
 
+    template <bool is_and>
+    void static do_not_null_pred(uint8_t* __restrict lhs, uint8_t* __restrict 
rhs, size_t size) {
+#ifdef NDEBUG
+#if defined(__clang__)
+#pragma clang loop vectorize(enable)
+#elif defined(__GNUC__) && (__GNUC__ >= 5)
+#pragma GCC ivdep
+#endif
+#endif
+        for (size_t i = 0; i < size; ++i) {
+            if constexpr (is_and) {
+                lhs[i] &= rhs[i];
+            } else {
+                lhs[i] |= rhs[i];
+            }
+        }
+    }
+
+    template <bool is_and>
+    void static do_null_pred(uint8_t* __restrict lhs_data, uint8_t* __restrict 
lhs_null,
+                             uint8_t* __restrict rhs_data, uint8_t* __restrict 
rhs_null,
+                             uint8_t* __restrict res_data, uint8_t* __restrict 
res_null,
+                             size_t size) {
+#ifdef NDEBUG
+#if defined(__clang__)
+#pragma clang loop vectorize(enable)
+#elif defined(__GNUC__) && (__GNUC__ >= 5)
+#pragma GCC ivdep
+#endif
+#endif
+        for (size_t i = 0; i < size; ++i) {
+            if constexpr (is_and) {
+                res_null[i] = apply_and_null(lhs_data[i], lhs_null[i], 
rhs_data[i], rhs_null[i]);
+                res_data[i] = lhs_data[i] & rhs_data[i];
+            } else {
+                res_null[i] = apply_or_null(lhs_data[i], lhs_null[i], 
rhs_data[i], rhs_null[i]);
+                res_data[i] = lhs_data[i] | rhs_data[i];
+            }
+        }
+    }
+
     bool _has_const_child() const {
         return std::ranges::any_of(_children,
                                    [](const VExprSPtr& arg) -> bool { return 
arg->is_constant(); });


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to