stdpain opened a new issue #5312:
URL: https://github.com/apache/incubator-doris/issues/5312


   Our current Top N sorting is implemented using priority queues, and we can 
often see this kind of code.
   But actually we want to pop the top element of the heap and insert a new 
element operation can be merged.
   For example, if we pop up and insert an element in a large top pile, we can 
first replace the top element with a new element, and then adjust it down to 
the pile. This comparison with the previous logic can reduce a heap adjustment.
   Here are my test results:
   ```sql
    select LO_ORDERKEY from LINE_ORDER_V2 order by LO_ORDERKEY desc limit $x;
   ```
   
   | before | after | limit |
   | ------ | ----- | ----- |
   | 1.92   | 1.05  | 10    |
   | 2.47   | 1.76  | 150   |
   | 3.40   | 2.94  | 1000  |
   
   ```sql
    select * from LINE_ORDER_V2 order by LO_ORDERKEY desc limit 10;
   ```
   
   | before | after | limit |
   | ------ | ----- | ----- |
   | 5.12   | 4.85  | 10    |
   
   
   It can be seen that the effect is very obvious in the single column.
   But as the number of columns increases. We can see that the speed increase 
is not particularly obvious. This is because the bottleneck at this time is not 
the sorting comparison itself, but the memory copy.


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

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