4张表级联查询的结果分组求和:

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
select sum(c.quantity) as quantity,sum(c.prefee) as fee
from  Cs_AccountBill a
join Cs_AccountBillDetail b on a.id= b.AccountBillId
join Cs_SettlementDetail c on c.accountBillDetailID = b.id 
join Cs_Settlement d on c.settlementID = d.id

While it's about 21W records of the result,time of select is about 31 ms.

更改如下:

select c.quantity,c.prefee
from  Cs_AccountBill a
join Cs_AccountBillDetail b on a.id= b.AccountBillId
join Cs_SettlementDetail c on c.accountBillDetailID = b.id 
join Cs_Settlement d on c.settlementID = d.id

  

查询时间:40ms左右

 

再将查询的结果map reduce 大概80+ms

BigDecimal sum = list.parallelStream().map(Person::getFee).reduce(BigDecimal::add).get();

//勿用list.stream(),慢

  

  

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄