Comments (2)
耗时比较长的这个,主要就是批量写入 task_instance_host 表, DAO 层是使用 Jooq。代码如下:
public void saveTaskInstanceHosts(long taskInstanceId,
Collection<HostDTO> hosts) {
BatchBindStep batchInsert = ctx.batch(
ctx.insertInto(TASK_INSTANCE_HOST, TASK_INSTANCE_HOST.TASK_INSTANCE_ID,
TASK_INSTANCE_HOST.HOST_ID, TASK_INSTANCE_HOST.IP, TASK_INSTANCE_HOST.IPV6)
.values((Long) null, null, null, null)
);
for (HostDTO host : hosts) {
batchInsert = batchInsert.bind(
taskInstanceId,
host.getHostId(),
host.getIp(),
host.getIpv6()
);
}
batchInsert.execute();
}
from bk-job.
原因
如果 jdbc 为设置rewriteBatchedStatements= false (默认), 那么即使是调用 Statement.executeBatch(), 也是逐个执行 SQL。关于rewriteBatchedStatements这个参数的介绍:
MySQL的JDBC连接的url中要加rewriteBatchedStatements参数,并保证5.1.13以上版本的驱动,才能实现高性能的批量插入。MySQL JDBC驱动在默认情况下会无视executeBatch()语句,把我们期望批量执行的一组sql语句拆散,一条一条地发给MySQL数据库,批量插入实际上是单条插入,直接造成较低的性能。只有把rewriteBatchedStatements参数置为true, 驱动才会帮你批量执行SQL。另外这个选项对INSERT/UPDATE/DELETE都有效。
参考
from bk-job.
Related Issues (20)
- feat: 文件分发增加增量分发功能
- fix: 全局设置中windows默认账号命名规则与描述不符
- perf: 脚本编辑器增加日志输出大小限制提醒 tips
- feat: 容器执行支持灰度
- fix: 运营分析数据最后更新时间不准确
- fix: get_step_instance_status接口缺少所有结果分组的基本信息
- fix: 文件分发添加本地大文件上传失败
- feat: 本地文件上传类型限制,需要支持.xx.xx类型
- perf: 脚本任务执行结果拉取优化
- fix: job 调用 cmdb list_kube_workload api 查询条件不正确导致循环查询
- fix: 定时任务服务更新后偶现任务不触发
- perf: 执行微服务进程 OOM 之后,确保任务能够重新调度
- feat: 执行历史归档源 DB 支持独立配置
- fix: 跨环境导入含本地文件作业后本地文件失效
- fix: 轻量化部署模式下分发配置文件失败 HOT 1
- perf: 将依赖Agent的Pod所在节点是否安装Agent作为健康指标之一
- feat: 作业平台支持修改账号管理中用户信息的API接口
- fix: 普通用户没有删除公共脚本管理权限,去申请跳转至404页面
- perf: 微服务调用 k8s service 请求重试机制优化
- fix: 主机选择器的手动输入,中文顿号会导致无法正常解析IP地址
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bk-job.