lgbo-ustc opened a new issue, #7895:
URL: https://github.com/apache/incubator-gluten/issues/7895

   ### Description
   
   To compute the average of integers, vanilla need to convert the integers 
into doubles first.
   
   Compare the following two ways  in `CH`
    
   ```sql
   1 row in set. Elapsed: 0.015 sec. Processed 10.00 million rows, 80.00 MB 
(655.54 million rows/s., 5.24 GB/s.)
   Peak memory usage: 113.21 KiB.
   
   f2386dc7dd0d :) select avg(cast(number as Double)) from numbers(10000000);
   
   SELECT avg(CAST(number, 'Double'))
   FROM numbers(10000000)
   
   Query id: 531d1858-0afa-4bcd-9e03-4615f129b978
   
      ┌─avg(CAST(number, 'Double'))─┐
   1. │                   4999999.5 │ -- 5.00 million
      └─────────────────────────────┘
   ```
   
   ```sql
   f2386dc7dd0d :) select avg(cast(number as Double)) from numbers(10000000);
   
   SELECT avg(CAST(number, 'Double'))
   FROM numbers(10000000)
   
   Query id: 235d8e41-19e5-4b94-92b5-b400fe10fdee
   
      ┌─avg(CAST(number, 'Double'))─┐
   1. │                   4999999.5 │ -- 5.00 million
      └─────────────────────────────┘
   
   1 row in set. Elapsed: 0.039 sec. Processed 10.00 million rows, 80.00 MB 
(258.45 million rows/s., 2.07 GB/s.)
   Peak memory usage: 114.16 KiB.
   ```
   
   Removing the cast operation will bring significant improvement.


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