Hibernate doesn't enable write batching by default. This means that it will send a separate SQL statement for each insert/update operation, greatly limiting write performance.
Enabling write batching will greatly improve write performance.
However, as per the Hibernate documentation for IDENTITY generation:
Hibernate will not be able to batch INSERT statements for the entities using the IDENTITY generation.
We are presently using IDENTITY generation. Thus it is required to change the ID generation strategy from IDENTITY to SEQUENCE generator. This also requires a change to database schema: instead of auto-incrementing the fragment ID, a sequence generator is added, allowing Hibernate to assign IDs before writing, by requesting the next ID from a sequence that increases by some allocation size (50 in this case):
The FragmentEntity class can be configured with appropriate annotations to use the sequence generator:
And the write batching can be finally enabled with appropriate config in application.yml: