java - Spring Data JPA saveAll 不进行批量插入
问题描述
所以我使用了一个简单的 JpaRepository 并调用了saveAll()方法。
hibernate.jdbc.batch_size = 500
hibernate.order_inserts = true
hibernate.generate_statistics = true
运行应用程序后:
8045055 nanoseconds spent acquiring 1 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
137189246 nanoseconds spent preparing 1158 JDBC statements;
1417689514 nanoseconds spent executing 1158 JDBC statements;
0 nanoseconds spent executing 0 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
0 nanoseconds spent performing 0 L2C hits;
0 nanoseconds spent performing 0 L2C misses;
16270990 nanoseconds spent executing 1 flushes (flushing a total of 1158 entities and 0 collections);
0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
任何人都可以看到 0 执行 JDBC 批处理的原因吗?另外,我必须指出我的实体有 @GeneratedValue(strategy = IDENTITY)主键
解决方案
Hibernate 不使用身份标识符生成器执行插入批处理。更多信息在这里。
推荐阅读
- php - 数组值自动增加一个设定值(例如,如果第一个是 echo $myarray[5];下一个是 echo $myarray[5+5];所以真的是 $myarray[10];)
- sql - 无法在 phpmyadmin 中显示空值,对我做错了什么有任何解释吗?
- python - Flask/Dash CSV/Excel 文件下载/输出对于不同实例中的每个用户不是唯一的
- python - 减少字符串上的冗余条件列表
- mysql - 在一个Mysql表中添加多个FK
- angular - 共享 Angular 上的 PhpStorm 和智能感知问题 - Nativescript 项目
- macos - 禁止 dyld 加载消息
- swift - 是否有一个真正的错误方法来查看当前的 SKView 是什么?
- kotlin - kotlin REPL 是否具有代码完成功能?
- ios - 如何使用 SwiftyJSON 读取数组中的 JSON 数据?