简体   繁体   中英

generating sql queries from mybatis xml queries

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM