Affects: \ 5.1.7
We are evaluating Spring-JDBC+ DBCP to communicate with IBM DB2 Server.
However we found the process time of each query increase continuously when use perform massive query with same SQL statement:
It is reasonable to require overhead for connection and statement management, but we would like to know if those overhead costs double process time to pure DBCP?
Sample Project is prepared for reference: https://github.com/shin779/mybatis-integration
Comment From: bclozel
Thanks for raising this, but we can't spend much time digging into a custom benchmark on a Spring Framework version that's not covered by OSS support anymore.
If you'd like to make progress here, please: * re-run your benchmark with the latest supported version of Spring Framework * use a Java Profiler to pinpoint where that extra time is being spent.
Comment From: mdeinum
I've taken a look at the test I would say the test is wrong.
- The configuration is using Commons DBCP1 for the
JdbcTemplate
whilst the plainDataSource
uses Commons DBCP2! JdbcTemplate
will close the connection, statement and resultsset each time, the test with the plain is only closing the connection at x iterations.- The test only executes the query, doesn't parse the result,
JdbcTemplate
does that including creating a list of maps
If you take all that into account (and thus create a proper test) the results are pretty much the same. Finally creating benchmark tests using System.currentTimesMillis
is generally not the best way of doing a performance test.
Comment From: bclozel
Thanks for your analysis @mdeinum I'm closing this issue as a result.
Comment From: shin779
Thanks for your reply and sorry for misleading.
In fact, we are using an ORM library "MyBatis" to communicate with database.
We use select
query via the DAOs (which is managed by Spring) and find it need more process time than without Spring.
(You can find in my sample project https://github.com/shin779/mybatis-integration, which both with and with Spring use DBCP)
It make sense that parsing result object and open/close connections, both Spring JDBC and MyBatis need such action but it is faster when Spring is not invoked.
We are looking into those process and find if it can be optimized. Thank you.
Comment From: mdeinum
MyBatis isn't Spring JDBC and thus this issue still isn't proper. That and your test is still wrong. You are comparing apples and oranges. Your test uses many sessions when using Spring (1 for each call) whereas with your plain test you are reusing the same session. Hence not opening/closing resources etc. etc.
So as long as you aren't comparing the same things, your test doesn't tell you anything.
Fixing the test to properly test the same thing, there are just some small differences between MyBatis and Spring or plain MyBatis. Sometimes the one is faster, sometimes the other. They level out around the same performance.
Comment From: shin779
Dear @mdeinum,
Thank you for your comment and we realised the process time increases is due to the Spring Transation Manager.
We invoke Spring Transation Manager from MyBatis described here, then the query times increased inside transation unless we close and create another transation after a certain number of query (say rollback / commit transation every 1000 queries).
We are wondering if it is due to the number of action inside transation. As the current implemenation will not rollback / commit unless the whole process finished, we are looking hints or configuration to allow the transation to store more action without making the process time longer and longer.
https://github.com/shin779/DBTestMyBatisSpringWithTxMgr