weixin_43914888
梓隽
采纳率100%
2019-11-18 15:46

MybatisPlus SQL执行时间太长

5
已采纳

今天遇到这样一个报错

### SQL: SELECT  id,zcbi,bgqmc,bgqmccn,lybh,lybhcn,yjxtfl,yjxtflcn,ejxtfl,ejxtflcn,sjxtfl,sjxtflcn,sblb,sblbcn,sbmc,sbmccn,xh,pp,ppcn,snh,ipdz,lc,lccn,mph,wlzjgi,zbksrq,zbjsrq,zbfgsmc,zbflxr,zbflxdh,sbgnms,pdfs,pdfscn,sfglrj,sfglrjcn,rjms,bz,sjzt,ssgs,ssgscn,sjjd,sjjdcn,jb,zccode,cclrry,cclrrycn,cw,delflag,oper,opercn,operip,operdept,operdeptcn,opertime,sydw,sydwcn,syr,sbje,sybm,syrdh,fwqpz  FROM t_yjzc_lr_table     WHERE sjjd <> ?
### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException:  The SQL execution time is too large, please optimize !
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) ~[mybatis-3.5.1.jar:3.5.1]
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149) ~[mybatis-3.5.1.jar:3.5.1]
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) ~[mybatis-3.5.1.jar:3.5.1]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ~[mybatis-spring-2.0.1.jar:2.0.1]
        ... 85 common frames omitted
Caused by: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException:  The SQL execution time is too large, please optimize !
        at com.baomidou.mybatisplus.core.toolkit.ExceptionUtils.mpe(ExceptionUtils.java:49) ~[mybatis-plus-core-3.1.1.jar:3.1.1]
        at com.baomidou.mybatisplus.core.toolkit.Assert.isTrue(Assert.java:38) ~[mybatis-plus-core-3.1.1.jar:3.1.1]
        at com.baomidou.mybatisplus.core.toolkit.Assert.isFalse(Assert.java:50) ~[mybatis-plus-core-3.1.1.jar:3.1.1]
        at com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor.intercept(PerformanceInterceptor.java:192)
~[mybatis-plus-extension-3.1.1.jar:3.1.1]
        at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) ~[mybatis-3.5.1.jar:3.5.1]
        at com.sun.proxy.$Proxy105.query(Unknown Source) ~[na:na]
        at sun.reflect.GeneratedMethodAccessor115.invoke(Unknown Source) ~[na:na]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
        at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) ~[mybatis-3.5.1.jar:3.5.1]
        at com.sun.proxy.$Proxy105.query(Unknown Source) ~[na:na]
        at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:67) ~[mybatis-plus-core-3.1.1.jar:3.1.1]
        at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) ~[mybatis-3.5.1.jar:3.5.1]
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) ~[mybatis-3.5.1.jar:3.5.1]
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) ~[mybatis-3.5.1.jar:3.5.1]
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) ~[mybatis-3.5.1.jar:3.5.1]
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) ~[mybatis-3.5.1.jar:3.5.1]
        ... 91 common frames omitted


我把sql沾出来,看执行时间也不长啊为什么报这个错
图片说明

也没有加sql性能分析插件,把mybatis的超时时间改成default-statement-timeout: 600也就是10分钟也不行。求大神帮帮看看

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • weixin_39508065 Elsa丶熊大 2年前

    把myites-plus的日志取消

    点赞 1 评论 复制链接分享
  • weixin_42195284 阿里巴巴首席技术官 2年前

    你加性能插件了
    例如如下:
    可以这样配置

        @Bean 
        public PerformanceInterceptor performanceInterceptor() {
            PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
            performanceInterceptor.setMaxTime(999); // 修改时间
    
            return performanceInterceptor;
        }
    
    点赞 评论 复制链接分享