linrrzqqq opened a new pull request, #64624:
URL: https://github.com/apache/doris/pull/64624

   Problem Summary:
   
   Before this change, all aggregate arguments followed the same runtime path:
   1. expression execution for every input argument,
   2. column materialization in the hot path,
   3. repeated reading of arguments that are semantically constant.
   
   For percentile-style functions, this is unnecessary for arguments such as 
the percentile level or the quantile array, because those values are fixed at 
function initialization time. Re-processing them for every block adds avoidable 
CPU overhead and becomes visible in high-throughput queries.
   
   This change introduces a dedicated constant-argument path:
   
   - constant arguments are evaluated once in open(),
   - the evaluated values are cached inside the aggregate function instance,
   - execution skips repeated evaluation and materialization for those 
arguments,
   - non-constant arguments continue to use the existing runtime path.
   
   
   before
   
   ```sql
   Doris> select percentile_array(FUniqID, [0.12, 0.23, 0.34, 0.45, 0.56, 0.67, 
0.78, 0.89, 0.91]) from hits_100m;
   
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | percentile_array(FUniqID, [0.12, 0.23, 0.34, 0.45, 0.56, 0.67, 0.78, 0.89, 
0.91])                                           |
   
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | [0, 5.097819197233503e+18, 5.68906185719365e+18, 6.281280528073601e+18, 
6.869583632113269e+18, 7.459044216605808e+18, 8.044902013692362e+18, 
8.640523572825436e+18, 8.749975206154981e+18] |
   
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   1 row in set (5.207 sec)
   ```
   
   now:
   
   ```sql
   Doris> select percentile_array(FUniqID, [0.12, 0.23, 0.34, 0.45, 0.56, 0.67, 
0.78, 0.89, 0.91]) from hits_100m;
   
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | percentile_array(FUniqID, [0.12, 0.23, 0.34, 0.45, 0.56, 0.67, 0.78, 0.89, 
0.91])                                                                          
                                |
   
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | [0, 5.097819197233503e+18, 5.68906185719365e+18, 6.281280528073601e+18, 
6.869583632113269e+18, 7.459044216605808e+18, 8.044902013692362e+18, 
8.640523572825436e+18, 8.749975206154981e+18] |
   
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   1 row in set (2.301 sec)
   ```
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to