求助,批量插入大量数据应该用什么方法
controller里面是这样的,
def computeAllCommunityLiquidityScore(){
def db = new groovy.sql.Sql(dataSource)
def communitySql="select community_id from COMMUNITY"
def communityResult = db.rows(communitySql).asList()
communityResult?.each{
communityService.communityMobilityScore(it?.community_id.toString())
}
}
community里面大概用56万数据,我需要跑一遍数据因为还要在service里面计算,每个communityId计算大概5项的值。都需要存入库中。现在计算一条communityId的速度是1s以内。我再本地开发环境测试批量跑,速度太慢,有什么好点的方法吗?
数据库用的是pg库。