4张表级联查询的结果分组求和:
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(),慢