baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.41k stars 4.31k forks source link

关于分页的sql效率问题 #60

Closed hbyangjianquan closed 7 years ago

hbyangjianquan commented 7 years ago

你好,使用mybatis plus分页插件功能,我看后台生成的查询count数量的sql是这样的SELECT COUNT(1) FROM ( SELECT * FROM t_mail_save order by receive_time DESC(我的sql) ) TOTAL ,这样貌似效率会很低,虚心求解

yuxiaobin commented 7 years ago

可以配置count的策略: http://mp.baomidou.com/#/page-plugin?id=%e5%88%86%e9%a1%b5%e6%8f%92%e4%bb%b6

hbyangjianquan commented 7 years ago

这个地方看过了,按照文档指定的springmvc的那个demo也配置了aliDruid的方式,但是还是一样的count,所以才来这儿请教下您,感谢~

qmdx commented 7 years ago

@hbyangjianquan spring 注入 mybats 插件配置,默认 mybatis.xml 可能不会注入自定义配置

yuxiaobin commented 7 years ago

这个小坑 写进文档吧