4
mybatis sql查询条件有两个字段同时判断数字大于等于0时查询效率非常慢
source link: https://www.oschina.net/question/3112043_2324878
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
mybatis sql查询条件有两个字段同时判断数字大于等于0时查询效率非常慢
将sql语句在数据库查询速度不过1秒都不到在在后台却发现非常慢,通过打印dao方法时间和看mybatis log发现速度确实是很慢不是其他问题,慢就慢在同时有两个字段判断小于等于0所致,有什么好的方法优化一下吗
ArchitectureMaster
昨天 11:05
楼上说得是对的,题主需要的是跑个计划分析。与其在程序里分析SQL语句,不如直接 在数据库里跑一下计划分析或explain。计划分析会告诉你哪一段sql脚本执行的速度,这时再针对于不同的情况采用不同的优化方案这才样会比较好。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK