zoukankan      html  css  js  c++  java
  • mybatisplus----性能分析插件

    性能分析插件


    我们在平时的开发中,会遇到一些慢sql。测试!druid,..

    作用:性能分析拦截器,用于输出每条SQL语句及其执行时间


    MP也提供性能分析插件,如果超过这个时间就停止运行!

    步骤:
    1、导入插件

        @Bean//性能分析插件
        @Profile({"dev", "test"})
        public PerformanceInterceptor performanceInterceptor() {
    
            PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
            performanceInterceptor.setMaxTime(100);//设置最大执行时间是1毫秒,超过1毫秒则sql语句不执行
            performanceInterceptor.setFormat(true);//开启格式化支持(输出的sql更加清楚)
    
            return performanceInterceptor;
        }

    配置文件中配置环境:

    #配置性能分析插件(显示每一条sql语句,和他的执行时间)
    spring.profiles.active=dev


    2、测试使用!!

        @Test
        void contextLoads() {
            //继承了BaseMapper所有的方法都来自于父类,当然我们也可以定义自己的方法
    
            //参数wrapper是一个条件构造器
            List<User> users = userMapper.selectList(null);
            users.forEach(System.out::println);
        }

     测试结果:

    迎风少年
  • 相关阅读:
    ruby_debug笔记
    来自Neil
    rails 在迭代里的那些条件
    rails 表单嵌套
    rails present? 和 blank? 对于bool 值
    泛泛
    设计模式——策略模式
    Spring容器初始化过程
    Spring之ResourceLoader加载资源
    Spring之ClassPathResource加载资源文件
  • 原文地址:https://www.cnblogs.com/ZYH-coder0927/p/13970368.html
Copyright © 2011-2022 走看看