I'm wondering why MyBatis is slow in my application.
For a SELECT COUNT(*)
, the time taken is:
Caching, most likely, is making the subsequent requests faster.
Disabled logging
I don't know if disabling both the logging subsystem and log4j makes a difference; but, the best I got was 15 secs for the SELECT COUNT(*)
.
Disabled Caching and Lazy loading
This too probably made a 5 sec difference at most.
The above techniques are listed here:
For a nested SQL statement with 2 joins and 1 sub-query, the time taken is:
I got the problems solved! MyBatis now takes the same time to query as running directly against the database.
It was the N+1 selects problem (nicely described here).
Nested Results (as opposed to Nested Select), which is also described on the same page mentioned above.
The difference it made to my SQL query with 4 joins was enormous:
I tracked the problem down by isolating it to a JUnit test-case around MyBatis-Spring (removing the JBoss part).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With