Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 1.14 KB

performance-analysis-plugin.md

File metadata and controls

43 lines (34 loc) · 1.14 KB

性能分析插件

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

  • 使用如下:
<plugins>
    ....

    <!-- SQL 执行性能分析,开发环境使用,线上不推荐。 maxTime 指的是 sql 最大执行时长 -->
    <plugin interceptor="com.baomidou.mybatisplus.plugins.PerformanceInterceptor">
        <property name="maxTime" value="100" />
        <!--SQL是否格式化 默认false-->
        <property name="format" value="true" />
    </plugin>
</plugins>
//Spring boot方式
@EnableTransactionManagement
@Configuration
@MapperScan("com.baomidou.cloud.service.*.mapper*")
public class MybatisPlusConfig {

    /**
     * SQL执行效率插件
     */
    @Bean
    @Profile({"dev","test"})// 设置 dev test 环境开启
    public PerformanceInterceptor performanceInterceptor() {
        return new PerformanceInterceptor();
    }
}

注意!参数说明

  • 参数:maxTime SQL 执行最大时长,超过自动停止运行,有助于发现问题。
  • 参数:format SQL SQL是否格式化,默认false。

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