4张表级联查询的结果分组求和:
select sum(c.quantity) as quantity,sum(c.prefee) as feefrom Cs_AccountBill ajoin Cs_AccountBillDetail b on a.id= b.AccountBillIdjoin 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.prefeefrom Cs_AccountBill ajoin Cs_AccountBillDetail b on a.id= b.AccountBillIdjoin 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(),慢