I got following results
1. ExecutoreType : REUSE
1.1 If inside the loop there is only SELECT statement it works fine
- query parsed once ("reused)
- number of execution = number of iterations
- number of fetches - according to fetchsize
1.2 If inside the loop there are SELECT and UPDATE, "reuse" actually does not work
- every select is parsed everytime it is executed = number of iterations
- every update is parsed everytime it is executed = number of iterations
- FetchSize works with select (expected)
- updates - updates every row individually - one-by-one (expected)
2. ExecutoreType : BATCH
Gives the best result, since it allows updating databases with "batches", batchsize is controlled programmatically by code.
- every select is parsed everytime it is executed = number of iterations
- every update is parsed everytime it is executed = number of iterations
- FetchSize works with select (expected)
- update is executed only N number of times, depend on "update batch size"
3. Tried to switch ExecutorType within the loop
Actually this is the worst.
- select still is parsed everytime it is executed
- updated is parsed with every row it updates
So in the summary I have following questions
Q1. Why with ExecutorType.REUSE it stops "reuses" if we have a mix of selects/updates?
Q2. Why are REUSE/BATCH mutually exclusive? Other words, is there any way now, or will it be in the future to combine the best of REUSE/BATCH, that will allow to avoid unnecessary and performance impacting soft parses on the database side, but update the database with "batches"?
I have one more question to be honest, I was trying to use MyBatis with Spring framework as well, and there was a complete disaster. Despite all my efforts (define default-executor-type in application.properties, set up configuration through JAVA API, passing ExecutorType.BATCH to sqlSessionFactory.openSession, I haven't managed to make it work in "batch" mode. Soe extra question is
Q3. How to make ExecutorType.BATCH work with MyBatis inside Spring Framework
I will totally understand if you ignore my mail, since I am not sure this is right communication channel, but I will highly appreciate if you comment on my questions/concerns
Thank you in advance