当前位置:网站首页>实战业务优化方案总结---主目录---持续更新
实战业务优化方案总结---主目录---持续更新
2022-04-23 18:33:00 【殷丿grd_志鹏】
总结在工作中遇到的有意思的问题,和对应解决方案。遇到一个记录一个。
业务大了,经常会出现莫名其妙的问题。比如好好的插件,莫名其妙不起作用了。这时候不可以改业务代码,或者修改一点点,还得解决问题。
文章目录
一、Mybatis爬坑
1. mybatis-plus 自动填充失效、分页插件不向下传递拦截链
问题如标题所示,mybatis自动填充不生效,使用分页插件发现这个插件没有向下传递拦截链。
解决方案
- 选择使用Mybatis-plus的分页插件,满足向下传递拦截链的要求。
- 仿造MyBatis-plus的自动填充使用,自定义自动填充插件。解决Mybatis-plus自动填充时而有效时而失效的情况。
由于篇幅原因,放在这篇文章:https://blog.csdn.net/grd_java/article/details/124349094 |
---|
2. 使用Spring AOP监控mapper执行时间
公司让优化报表的查询(一个查询据说将近20s,一个接口15秒会超时,所以最坏也得让查询在15s以内),这些报表数据量大,IO非常多,一个查询涉及到几十条sql和IO
因此想要优化,就得知道哪些操作比较费时间,直接用AOP是好的选择,精确打印每一个IO的时间,进行优化
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import java.util.Arrays;
/** * 2022-04-14===>>>yinzhipeng * 用于获取mapper执行时间 */
@Component
@Aspect
@Slf4j
public class MapperExecutionTimeAspect {
@Pointcut("execution(* cn.xxx.mapper.*.*(..))")
public void pointcut() {
}
@Around("pointcut()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
long begin = System.nanoTime();
Object obj = pjp.proceed();
long end = System.nanoTime();
log.info("调用Mapper方法:执行耗时:{}纳秒,耗时:{}毫秒,{},参数:{}",
(end - begin), (end - begin) / 1000000,
pjp.getSignature().toString(), Arrays.toString(pjp.getArgs()));
return obj;
}
}
二、查询优化
1. 大量mapper IO优化
当查询大报表,并且sql没有太大优化空间的情况下,该如何提升效率呢?
- 也就是说现在IO太多,但是也没办法,业务确实需要这么多的IO
- 单个IO的效率优化,已经没有太多优化空间了,也就是优化sql的方案不可取
- 那么问题就是如何让这些IO能快一点
一般这种情况,就可以考虑多线程了,而且大的报表一般是不用考虑高并发的。所以直接将内容都写到方法中,不定义到类中,就没有线程安全问题。因为没有高并发,也不用考虑栈溢出的问题(每个线程执行都会有一个,线程私有,生命周期与线程相同,是Java方法执行的线程内存模型,每个方法被执行时,Java虚拟机都会同步创建一个栈帧(Stack Frame)用于存储局部变量表、操作数栈、动态连接、方法出口等信息)
由于篇幅原因,放在这篇文章:https://blog.csdn.net/grd_java/article/details/124348962 |
---|
版权声明
本文为[殷丿grd_志鹏]所创,转载请带上原文链接,感谢
https://blog.csdn.net/grd_java/article/details/124346685
边栏推荐
- CANopen usage method and main parameters of object dictionary
- Test questions of daily safety network (February 2024)
- Rust: shared variable in thread pool
- 串口调试工具cutecom和minicom
- Serialization scheme of serde - trust
- Use stm32cube MX / stm32cube ide to generate FatFs code and operate SPI flash
- Promote QT default control to custom control
- CANopen STM32 transplantation
- SQL database syntax learning notes
- iptables初探
猜你喜欢
视频边框背景如何虚化,简单操作几步实现
listener.log
Matlab tips (6) comparison of seven filtering methods
Promote QT default control to custom control
Jeecg boot microservice architecture
Halo open source project learning (VII): caching mechanism
Custom prompt box MessageBox in QT
Robocode tutorial 3 - Robo machine analysis
ctfshow-web362(SSTI)
深度学习经典网络解析目标检测篇(一):R-CNN
随机推荐
In shell programming, the shell file with relative path is referenced
Log4j2 cross thread print traceid
QT tablewidget insert qcombobox drop-down box
C language simulates entering and leaving the stack, first in first out, first in first out, shared memory
昇腾 AI 开发者创享日全国巡回首站在西安成功举行
Gst-launch-1.0 usage notes
14个py小游戏源代码分享第二弹
PowerDesigner various font settings; Preview font setting; SQL font settings
Deep learning classic network analysis and target detection (I): r-cnn
Introduction to QT programming
Notepad + + replaces tabs with spaces
Robocode tutorial 5 - enemy class
Daily CISSP certification common mistakes (April 15, 2022)
Solution to Chinese garbled code after reg file is imported into the registry
Rust: how to match a string?
Mysql database backup command -- mysqldump
使用晨曦记账本,分析某个时间段每个账户收支结余
Imx6 debugging LVDS screen technical notes
SQL database syntax learning notes
ESP32 LVGL8. 1 - BTN button (BTN 15)