Reputation: 2311
I wrote an application using JPA. The application makes around 5 or 6 inserts per second on one Table. The insert is done by a simple Transaction begin, persist and transaction commit.
With this approach the application has a really heavy cpu load (around 80%). Using the JVisualVM i profiled the application and came to this result:
This shows that around 30% percent of the time is spent in writing and flushing to Log Files.
Also the setExclusive
method has a load of 14% of the time.
Is there a way to optimize this? Maybe disabling logging?
Upvotes: 2
Views: 320
Reputation: 547
enterbios is right. Disable the logging and you don’t have a database anymore, but simply SQL for writing to files (bye bye acid). As most databases do, Derby uses group commit, i.e. that the log for multiple transactions are grouped in a single disk write. But if you do a single update, commit, wait and then another insert the the group commit will have very little effect as there is only log from a single insert to write.
The setExclusive time points to contention for the same data (multiple threads accessing the same database page).
Upvotes: 1