Query 1000000 rows data, the fetch size is 1000,Mybatis costs 175 secon
ds,Ibatis costs 81 seconds.
Why Mybatis so slow? How can I optimize mybatis, or where do I configur
e incorrectly?
Do you have any profiling data? (VisualVM for example..)
But ok, if we are taking about 146 minutes I would bet the problem is
not in MyBatis.
First of all, I see you are using Spring.
The way MyBatis-Spring works for batches is not the same than for the
Spring official support for iBATIS 2 as you have already noticed.
There is not any "doInSqlMapClient", staments are automatically
batched if you are using a batch SqlSession, and will be flushed
automatically when Spring ends the transaction.
The important point here is that: if you are not starting correctly
the Spring transaction you are not doing any batch!
So, if you want to benchmark MyBatis vs iBATIS I would consider doing
it in a simpler scenario, thus without Spring.
Or if you want to use Spring for any reason ensure that TX is
correctly configured. You will see easily if it is working fine
enabling the log.
Let us know your progress and do not hesitate to ask for help.
It looks that most of the time is spent in parsing the SQL sentence.
We should have a look at that. Maybe we could do a fast parsing if
dynamic expresions like ${} are not detected.
I will re-open the issue you filled.
Thank you for the detailed info.
From the visualvm snapshot, I find that every upate action will parse
sql and create a statement. Whether could I parse sql first time, the f
ollow action in the batch insert only add batch as jdbc. If we can do i
t, it will save much time for batch insert.
That should MB3 work at least as fast as IB2.
I am afraid you can't. This is how MB is working right now so we need
to change that behaviour first.