postgresql批量新增数据时,批量插入的数据量太大了,造成了IO异常

只能把这么多数据先进行分割,再批量插入,但是感觉这种方式不是最优解,先暂时顶着,具体List分割方式如下:

package cn.ucmed.otaka.healthcare.cloud.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map; public class PartitionArray<T> { public Map<Integer, List<T>> partition(List<T> tArray, int capacity) {
if (tArray.isEmpty() || capacity < 1) {
return null;
}
Map<Integer, List<T>> result = new HashMap<>(); int size = tArray.size();
int count = ((Double) Math.ceil(size * 1.0 / capacity)).intValue(); for (int i = 0; i < count; i++) {
int end = capacity * (i + 1);
if (end > size) end = size;
result.put(i, tArray.subList(capacity * i, end));
}
return result;
}
}

原先批量调用的地方做个处理:

        try {
PartitionArray<MDynamicFuncReleaseHistory> partitionArray = new PartitionArray<>();
Map<Integer, List<MDynamicFuncReleaseHistory>> batchList = partitionArray.partition(releaseHistoryList, INSERT_CAPACITY);
batchList.forEach((k, v) -> {
mDynamicFuncReleaseHistoryMapper.batchInsert(v);
});
} catch (Exception e) {
log.error(e.getMessage());
throw new BusinessException(500, "新增MDynamicFuncReleaseHistory失败");
}

PSQLException: An I/O error occurred while sending to the backend.的更多相关文章

  1. 网站错误记录:A transport-level error has occurred when sending the request to the server.

    今天查看公司项目的日志文件,发现有这个错误:A transport-level error has occurred when sending the request to the server. 感 ...

  2. "A transport-level error has occurred when sending the request to the server,指定的网络名不在可用"的解决办法

    项目在外网服务器上运行的时候,遇到一个异常:"A transport-level error has occurred when sending the request to the ser ...

  3. "A transport-level error has occurred when sending the request to the server"的解决办法

    http://blog.csdn.net/luckeryin/article/details/4337457 最近在做项目时,遇到一个随机发生的异常:"A transport-level e ...

  4. xamarin IOS 报错处理: an error occurred on client Build420719 while

    xamarin IOS 开发时如果报错如下: an error occurred on client Build420719 while...... 出现如下问题时,可能是1.丢失文件2.没有包括在项 ...

  5. An error occurred during the installation of assembly 'Microsoft.VC90.CRT……的问题

    有一段时间没有用到AnkhSvn了,今天工作需要安装了一下.结果安装到一半就无法继续了,提示An error occurred during the installation of assembly ...

  6. Eclipse启动时发生An internal error occurred during: "Initializing Java Tooling".错误的解决方法

    问题描述: Eclipse启动时发生An internal error occurred during: "Initializing JavaTooling".错误的解决方法 解决 ...

  7. ORA-00604: error occurred at recursive SQL level 1

    在测试环境中使用某个账号ESCMOWNER对数据库进行ALTER操作时,老是报如下错误: ORA-00604: error occurred at recursive SQL level 1 ORA- ...

  8. 关于装完系统出现a disk read error occurred的解决方法

    今天偶遇一台老电脑,很久都没有用了,而且只有几百兆的内存,160G的硬盘,无奈只好装XP系统,GHOST完之后,开机发现出现a disk read error occurred的错误,但是用U盘引导可 ...

  9. An error occurred while collecting items to be installed

    安装的插件:Activiti 在Eclipse安装插件时,报以下错误: An error occurred while collecting items to be installed session ...

随机推荐

  1. 使用GitHub搜索技巧

    in:name example 名字中有"example"in:readme example readme中有"example"in:description e ...

  2. Matlab享元模式

    享元模式(Flyweight)通过共享技术实现相同或相似对象的重用,可以减少创建对象的数量,以减少内存占用和提高性能.Java String的常量池,python logging,线程池,数据库连接池 ...

  3. js之正则

    1.正则的声明方法 1)var reg = /abc/; "这个叫对象直接量方式": 2)var reg = new RegExp("abc") 这个叫构造函数 ...

  4. js学习之堆栈内存

    **栈内存** >基本数据类型值是直接存放在栈内存中的 栈内存中的变量一般都是已知大小或者有范围上限的,算作一种简单存储.而堆内存存储的对象类型数据对于大小这方面,一般都是未知的.个人认为,这也 ...

  5. 英语gzibeads天珠gzibeads单词

    天珠英语是gZiBeads,藏语叫(si , 斯)汉语译为“斯”或“瑟”,又称“天降石”.在<藏汉大辞典>里天珠的解释为:“亚玛瑙,猫睛石,一种宝石,俗称九眼珠.入药能治脑溢血”.最早的天 ...

  6. Cheat Engine 指针

    打开游戏 扫描时间的流程就不多说了 扫描结果 寻找基地址 右击扫描到的地址,选择什么改写了这个地址 会弹出如下窗口 不用管这个窗口,去改变一下游戏时间,出现如下图 随便打开一个,找到了数据块地址和偏移 ...

  7. Kubernetes学习之基础概念

    本文章目录 kubernetes特性 kubernetes集群架构与组件 一.kubernetes集群架构 二.集群组件 三.ubernetes集群术语 深入理解Pod对象 一.Pod容器分类 基础容 ...

  8. tensorflow 镜像

    https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/cpu/ 报错 不支持 C:\Users\brady\.conda\envs\tenso ...

  9. input限制输入

    input 只能输入数字.字母.汉字等   1.文本框只能输入数字代码(小数点也不能输入) <input onkeyup="this.value=this.value.replace( ...

  10. RxJS——订阅(Subscription)

    订阅(Subscription) 什么是订阅?订阅是一个对象,它表示一个处理完就释放(disposable)的资源,是 Observable 的一个执行程序.订阅有一个很重要的方法,unsubscri ...