当前位置:网站首页>实战业务优化方案总结---主目录---持续更新
实战业务优化方案总结---主目录---持续更新
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
边栏推荐
- Mysql database backup command -- mysqldump
- 回路-通路
- powerdesigner各种字体设置;preview字体设置;sql字体设置
- Win1远程出现“这可能是由于credssp加密oracle修正”解决办法
- Rust: how to match a string?
- In shell programming, the shell file with relative path is referenced
- With the use of qchart, the final UI interface can be realized. The control of qweight can be added and promoted to a user-defined class. Only the class needs to be promoted to realize the coordinate
- Test post and login function
- WiFi ap6212 driver transplantation and debugging analysis technical notes
- Differences between SSD hard disk SATA interface and m.2 interface (detailed summary)
猜你喜欢
The vivado project corresponding to the board is generated by TCL script
ctfshow-web361(SSTI)
Spark performance optimization guide
使用 bitnami/postgresql-repmgr 镜像快速设置 PostgreSQL HA
Kettle paoding jieniu Chapter 17 text file output
Teach you to quickly rename folder names in a few simple steps
使用晨曦记账本,分析某个时间段每个账户收支结余
Robocode tutorial 7 - Radar locking
Robocode tutorial 3 - Robo machine analysis
ctfshow-web362(SSTI)
随机推荐
Const keyword, variable and function are decorated with const
配置iptables
QT tablewidget insert qcombobox drop-down box
ESP32 LVGL8. 1 - anim animation (anim 16)
硬核解析Promise对象(这七个必会的常用API和七个关键问题你都了解吗?)
Daily CISSP certification common mistakes (April 19, 2022)
iptables -L执行缓慢
14个py小游戏源代码分享第二弹
STM32学习记录0008——GPIO那些事1
SQL database syntax learning notes
【数学建模】—— 层次分析法(AHP)
Promote QT default control to custom control
JD-FreeFuck 京東薅羊毛控制面板 後臺命令執行漏洞
STM32 learning record 0008 - GPIO things 1
QT curve / oscilloscope customplot control
函数递归以及趣味问题的解决
Function recursion and solving interesting problems
In shell programming, the shell file with relative path is referenced
串口调试工具cutecom和minicom
昇腾 AI 开发者创享日全国巡回首站在西安成功举行