Mybatis-Plus 性能分析插件

性能分析插件

我们平时的开发中,会遇到一些慢sql
mybatisplus提供的性能分析插件,如果超过这个时间就停止运行
作用:性能分析拦截器,用于输出每条SQL语句及执行时间

该插件只用于开发环境,不建议生产环境使用。

导入插件

 /**
 * SQL执行效率插件
 */
@Bean
@Profile({"dev","test"})// 设置 dev test 环境开启,保证效率
public PerformanceInterceptor performanceInterceptor() {
    PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
    performanceInterceptor.setMaxTime(100);    // ms 设置 SQL 执行的最大时间,如果超过了就不执行
    performanceInterceptor.setFormat(true);      //    开启格式化支持
    return performanceInterceptor;
}

在 SpringBoot 中配置环境为 dev 或 test

# 设置开发环境
spring.profiles.active=dev

测试:

Mybatis-Plus 性能分析插件_第1张图片

你可能感兴趣的:(Mybatis-Plus)