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. Windows下载安装RabbitMQ教程

    原文链接:http://www.studyshare.cn/software/details/1171/0一.下载 1.下载Erlang 官网下载:去下载 百度网盘下载:去下载  提取码:m1q0 2 ...

  2. PHP-FPM的相关知识的深度解释

    一.需要搞清楚几个名词概念 1.          CGI(Common Gateway Interface,CGI)通用网关接口, 是Web 服务器运行时外部程序的规范,按CGI 编写的程序可以扩展 ...

  3. 在win10、Ubuntu双系统下,卸载Ubuntu

    一.Win下确定ubuntu的磁盘分区 这个步骤是为了删除Ubuntu的系统分区,这种直接删除的方式来重新安装ubuntu的低版本比较省事. (1)右键计算机->管理->磁盘管理,打开磁盘 ...

  4. 鼠标按下改变RelativeLayout背景颜色,松开变回

    在drawable下创建bg.xml文件 <?xml version="1.0" encoding="utf-8"?> <selector x ...

  5. CSS 用法和特性

    一.CSS 基本用法 1.CSS 样式语法 样式是 CSS 最小的语法单元,每个样式包含两部分内容:选择器和声明(规则). 语法: p {font-size:12px; color:#333} 注意: ...

  6. PHP在线批量下载文件

    在项目开发中需要给客户提供在线下载文件的功能. 解决方案:使用PHP自带的ZipArchive类,将多个文件打包成zip文件,供客户下载! 使用ZipArchive类时,需要先开启php_zip扩展, ...

  7. redis-存储命令

    一.String类型: 1.赋值/取值 set key valueget key 2.设置/获取多个键值   mset key1 value1 key2 value2 …   mget key1 ke ...

  8. 排序算法的c++实现——插入排序

    插入排序的思想是:给定一个待排序的数组,我们从中选择第一个元素作为有序的基态(单个元素肯定是有序的), 然后从剩余的元素中选择一个插入到有序的基态中,使插入之后的序列也是有序状态,重复此过程,直到全部 ...

  9. 后缀表达式 Java实现

    基本原理: 从左到右扫描字符串:1.是操作数:压栈. 2.是操作符:出栈两个操作数,将运算结果压栈. 扫描字符串通过java.util.Scanner类实现,其next方法可以读取以空格(默认)或指定 ...

  10. linux设备驱动程序-i2c(0)-i2c设备驱动源码实现

    (基于4.14内核版本) 为了梳理清楚linux内核中的i2c实现框架,从本文开始,博主将分几个章节分别解析i2c总线在linux内核中的形成过程.匹配过程.以及设备驱动程序源码实现. 在介绍linu ...