Open chenmu5241 opened 1 year ago
我有1000多条数据想使用insert into table (id,name) values(1,''a),(,'b')这种批量sql执行,所以用了模板做的,竟然需要20多秒,不知道有办法优化吗
VALUES @foreach{item : list,index:list.size()} ( @if{item.id == null} null @else{} '@{item.id}' @end{}, @if{item.createTeamId == null} null @else{} '@{item.createTeamId}' @end{}, @if{item.createTeamName == null} null @else{} '@{item.createTeamName}' @end{}, @if{item.createTime == null} null @else{} '@{cn.hutool.core.date.DateUtil.format(item.createTime,"yyyy-MM-dd HH:mm:ss")}' @end{}, @if{item.creatorId == null} null @else{} '@{item.creatorId}' @end{}, @if{item.creatorName == null} null @else{} '@{item.creatorName}' @end{}, @if{item.status == null} null @else{} @{item.status} @end{}, @if{item.tenantId == null} null @else{} '@{item.tenantId}' @end{}, @if{item.tenantName == null} null @else{} '@{item.tenantName}' @end{}, @if{item.updateTime == null} null @else{} '@{cn.hutool.core.date.DateUtil.format(item.updateTime,"yyyy-MM-dd HH:mm:ss")}' @end{}, @if{item.updatorId == null} null @else{} '@{item.updatorId}' @end{}, @if{item.updatorName == null} null @else{} '@{item.updatorName}' @end{}, @if{item.address == null} null @else{} '@{item.address}' @end{}, @if{item.area == null} null @else{} '@{item.area}' @end{}, @if{item.categoryCode == null} null @else{} '@{item.categoryCode}' @end{}, @if{item.categoryName == null} null @else{} '@{item.categoryName}' @end{}, @if{item.classifyCode == null} null @else{} '@{item.classifyCode}' @end{}, @if{item.classifyName == null} null @else{} '@{item.classifyName}' @end{}, @if{item.facilityTypeCode == null} null @else{} '@{item.facilityTypeCode}' @end{}, @if{item.facilityTypeName == null} null @else{} '@{item.facilityTypeName}' @end{}, @if{item.isCharacteristic == null} null @else{} @{item.isCharacteristic} @end{}, @if{item.isCharacteristicName == null} null @else{} '@{item.isCharacteristicName}' @end{}, @if{item.latitude == null} null @else{} '@{item.latitude}' @end{}, @if{item.levelCode == null} null @else{} '@{item.levelCode}' @end{}, @if{item.levelName == null} null @else{} '@{item.levelName}' @end{}, @if{item.longitude == null} null @else{} '@{item.longitude}' @end{}, @if{item.mobile == null} null @else{} '@{item.mobile}' @end{}, @if{item.name == null} null @else{} '@{item.name}' @end{}, @if{item.remark == null} null @else{} '@{item.remark}' @end{}, @if{item.streetCode == null} null @else{} '@{item.streetCode}' @end{}, @if{item.streetName == null} null @else{} '@{item.streetName}' @end{}, @if{item.tag == null} null @else{} '@{item.tag}' @end{}, @if{item.telphone == null} null @else{} '@{item.telphone}' @end{}, @if{item.uploadBatchId == null} null @else{} '@{item.uploadBatchId}' @end{}, @if{item.approvalTime == null} null @else{} '@{cn.hutool.core.date.DateUtil.format(item.approvalTime,"yyyy-MM-dd HH:mm:ss")}' @end{}, @if{item.approverName == null} null @else{} '@{item.approverName}' @end{}, @if{item.approverUserId == null} null @else{} '@{item.approverUserId}' @end{}, @if{item.businessId == null} null @else{} '@{item.businessId}' @end{}, @if{item.checkRemark == null} null @else{} '@{item.checkRemark}' @end{}, @if{item.isLast == null} null @else{} @{item.isLast} @end{}, @if{item.optType == null} null @else{} '@{item.optType}' @end{}, @if{item.state == null} null @else{} @{item.state} @end{}, @if{item.buildingArea == null} null @else{} '@{item.buildingArea}' @end{}, @if{item.qualityCode == null} null @else{} '@{item.qualityCode}' @end{}, @if{item.qualityName == null} null @else{} '@{item.qualityName}' @end{} ) @if{index != list.size()-1},@end{} @end{}
我有1000多条数据想使用insert into table (id,name) values(1,''a),(,'b')这种批量sql执行,所以用了模板做的,竟然需要20多秒,不知道有办法优化吗
VALUES @foreach{item : list,index:list.size()} ( @if{item.id == null} null @else{} '@{item.id}' @end{}, @if{item.createTeamId == null} null @else{} '@{item.createTeamId}' @end{}, @if{item.createTeamName == null} null @else{} '@{item.createTeamName}' @end{}, @if{item.createTime == null} null @else{} '@{cn.hutool.core.date.DateUtil.format(item.createTime,"yyyy-MM-dd HH:mm:ss")}' @end{}, @if{item.creatorId == null} null @else{} '@{item.creatorId}' @end{}, @if{item.creatorName == null} null @else{} '@{item.creatorName}' @end{}, @if{item.status == null} null @else{} @{item.status} @end{}, @if{item.tenantId == null} null @else{} '@{item.tenantId}' @end{}, @if{item.tenantName == null} null @else{} '@{item.tenantName}' @end{}, @if{item.updateTime == null} null @else{} '@{cn.hutool.core.date.DateUtil.format(item.updateTime,"yyyy-MM-dd HH:mm:ss")}' @end{}, @if{item.updatorId == null} null @else{} '@{item.updatorId}' @end{}, @if{item.updatorName == null} null @else{} '@{item.updatorName}' @end{}, @if{item.address == null} null @else{} '@{item.address}' @end{}, @if{item.area == null} null @else{} '@{item.area}' @end{}, @if{item.categoryCode == null} null @else{} '@{item.categoryCode}' @end{}, @if{item.categoryName == null} null @else{} '@{item.categoryName}' @end{}, @if{item.classifyCode == null} null @else{} '@{item.classifyCode}' @end{}, @if{item.classifyName == null} null @else{} '@{item.classifyName}' @end{}, @if{item.facilityTypeCode == null} null @else{} '@{item.facilityTypeCode}' @end{}, @if{item.facilityTypeName == null} null @else{} '@{item.facilityTypeName}' @end{}, @if{item.isCharacteristic == null} null @else{} @{item.isCharacteristic} @end{}, @if{item.isCharacteristicName == null} null @else{} '@{item.isCharacteristicName}' @end{}, @if{item.latitude == null} null @else{} '@{item.latitude}' @end{}, @if{item.levelCode == null} null @else{} '@{item.levelCode}' @end{}, @if{item.levelName == null} null @else{} '@{item.levelName}' @end{}, @if{item.longitude == null} null @else{} '@{item.longitude}' @end{}, @if{item.mobile == null} null @else{} '@{item.mobile}' @end{}, @if{item.name == null} null @else{} '@{item.name}' @end{}, @if{item.remark == null} null @else{} '@{item.remark}' @end{}, @if{item.streetCode == null} null @else{} '@{item.streetCode}' @end{}, @if{item.streetName == null} null @else{} '@{item.streetName}' @end{}, @if{item.tag == null} null @else{} '@{item.tag}' @end{}, @if{item.telphone == null} null @else{} '@{item.telphone}' @end{}, @if{item.uploadBatchId == null} null @else{} '@{item.uploadBatchId}' @end{}, @if{item.approvalTime == null} null @else{} '@{cn.hutool.core.date.DateUtil.format(item.approvalTime,"yyyy-MM-dd HH:mm:ss")}' @end{}, @if{item.approverName == null} null @else{} '@{item.approverName}' @end{}, @if{item.approverUserId == null} null @else{} '@{item.approverUserId}' @end{}, @if{item.businessId == null} null @else{} '@{item.businessId}' @end{}, @if{item.checkRemark == null} null @else{} '@{item.checkRemark}' @end{}, @if{item.isLast == null} null @else{} @{item.isLast} @end{}, @if{item.optType == null} null @else{} '@{item.optType}' @end{}, @if{item.state == null} null @else{} @{item.state} @end{}, @if{item.buildingArea == null} null @else{} '@{item.buildingArea}' @end{}, @if{item.qualityCode == null} null @else{} '@{item.qualityCode}' @end{}, @if{item.qualityName == null} null @else{} '@{item.qualityName}' @end{} ) @if{index != list.size()-1},@end{} @end{}