I have a mybatis mapper file xml with complex queries lot of where clauses with conditions.
Is there any way I can create possible queries combination?
I want to run explain on all these queries as I am planning to add NOT IN
on all queries.
Using @MybatisTest The @MybatisTest can be used if you want to test MyBatis components(Mapper interface and SqlSession ). By default it will configure MyBatis(MyBatis-Spring) components( SqlSessionFactory and SqlSessionTemplate ), configure MyBatis mapper interfaces and configure an in-memory embedded database.
For an easiest query. Not considering the first query, for the following queries, JDBC always takes about 6ms~10ms, and MyBatis takes about 31~35ms, which is about 3 times. For a more complex query (6 inner joins and an order by in it), JDBC only takes 25~30ms, while MyBatis needs 80~100ms.
It is the same thing, a persistence framework! But until June 2010, iBatis was under Apache license and since then, the framework founders decided to move it to Google Code and they renamed it to MyBatis. The framework is still the same though, it just has a different name now.
Inetractive application In your place I would use some sort of load generator, record a macro on Selenium for example with some imputs clicking everywhere that could be clicked on your application so that the targeted SQLs are triggered. Then I would put one recorder to log and dump all the SQL queries. I will analyse the log , pick up all the different samples and run them against the DB with explain plan.
Its a bit of a workaround solution , but I believe it will do the trick.
For a non interactive application, where UI or SOAP or REST recording is not an option. For exaple some sort of networking based application or a batch application or whatever.... If we suppose it is a batch, I would just let it play record the SQLs and again do explain. A lot of databases can do that on the fly actualy. For example if you use "Query monitor" on DB2 it records all queries in certain timeframe and than you can see the heaviest ones, or just the most commonly occuring ones and do explain. My expectation is other databases may have similar functionality if not you just dump the sqls on the application side. Plenty of options there http://www.rgagnon.com/javadetails/java-0602.html
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