Hello, I’m currently working on enhancing write performance by changing to to batch inserts, but looking at the DB logs it does not appear to be working. I am using hibernate version 5.4.25 on MySQL 5.7 with the standard batching loop from hibernate docs here: Hibernate ORM 5.4.30.Final User Guide. To set the JDBC batch size, I am using the call to sesssion.setJdbcBatchSize
seen here: SharedSessionContract (Hibernate JavaDocs)
I’ve enabled logging for statistics as well as BatchingBatch
and this was the output:
[ BatchingBatch ] - Executing batch size: 3
[ StatisticalLoggingSessionEventListener ] - Session Metrics {
4587 nanoseconds spent acquiring 1 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
237535 nanoseconds spent preparing 1 JDBC statements;
0 nanoseconds spent executing 0 JDBC statements;
7376834 nanoseconds spent executing 1 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
0 nanoseconds spent performing 0 L2C hits;
0 nanoseconds spent performing 0 L2C misses;
42524632 nanoseconds spent executing 1 flushes (flushing a total of 3 entities and 6 collections);
0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
}
However, when going to the general logs for MySQL, I can still see 3 individual insert statements rather than a single multi-valued insert. It is worth noting that the identifier generation is done in the app not in MySQL. I am not understanding why the rewrite is not occurring, so any help would be appreciated.