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

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #xxx
   
   Problem Summary:
   
   ### Key Optimizations
   - Reworked exact percentile state into a simpler `values + PercentileLevels 
+ inited_flag` layout.
   - Removed the old Counts-based exact percentile path and replaced it with a 
lightweight `PercentileLevels` metadata structure.
   - Reduced add-path overhead by directly appending values into a contiguous 
buffer and initializing percentile levels only once.
   - Optimized multi-quantile finalize by sorting quantiles through permutation 
once, then reusing incremental nth_element selection.
   - Simplified serialization / merge logic to avoid extra exact-state overhead.
   
   ### Performance
   before:
   ```text
   Doris> select percentile(FUniqID, 0.91) from hits_100m;
   +---------------------------+
   | percentile(FUniqID, 0.91) |
   +---------------------------+
   |     8.749975206154981e+18 |
   +---------------------------+
   1 row in set (6.149 sec)
   
   Doris> select percentile_array(FUniqID, [0.12, 0.23, 0.34, 0.45, 0.56]) from 
hits_100m;
   
+------------------------------------------------------------------------------------------------+
   | percentile_array(FUniqID, [0.12, 0.23, 0.34, 0.45, 0.56])                  
                    |
   
+------------------------------------------------------------------------------------------------+
   | [0, 5.097819197233503e+18, 5.68906185719365e+18, 6.281280528073601e+18, 
6.869583632113269e+18] |
   
+------------------------------------------------------------------------------------------------+
   1 row in set (28.984 sec)
   
   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;
   ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[E-3113]string 
column length is too large: total_length=7200000149, element_number=0, rows=0
   ```
   
   now
   ```text
   Doris> select percentile(FUniqID, 0.91) from hits_100m;
   +---------------------------+
   | percentile(FUniqID, 0.91) |
   +---------------------------+
   |     8.749975206154981e+18 |
   +---------------------------+
   1 row in set (2.107 sec)
   
   Doris> select percentile_array(FUniqID, [0.12, 0.23, 0.34, 0.45, 0.56]) from 
hits_100m;
   
+------------------------------------------------------------------------------------------------+
   | percentile_array(FUniqID, [0.12, 0.23, 0.34, 0.45, 0.56])                  
                    |
   
+------------------------------------------------------------------------------------------------+
   | [0, 5.097819197233503e+18, 5.68906185719365e+18, 6.281280528073601e+18, 
6.869583632113269e+18] |
   
+------------------------------------------------------------------------------------------------+
   1 row in set (5.903 sec)
   
   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 (8.866 sec)
   ```
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [x] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [x] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [x] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


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