当前位置:网站首页>查询优化(TTFB过长)left join索引未生效
查询优化(TTFB过长)left join索引未生效
2022-08-05 11:46:00 【夏至青柠】
今天发现页面初始化加载时间过长,(TTFB)等待状态竟然花费了近7s,要对此页面加载进行优化,减少加载时间
执行页面查询对应的sql;发现table f的type为ALL,以为未加索引;
找到该表查看,有索引;那么问题应该就是索引未生效;想了一下失效的种种原因竟然都不满足,有点纳闷;
最后发现JBS_PROJECT_PROFIT f ON f.PROJECT_ID = p.ROW_ID中的f.PROJECT_ID = p.ROW_ID字符集和排序规则不同;于是统一之后,sql执行时间未0.5s,页面立马加载好了。索引成功优点很明显,极大提高了查询效率。
总结一下:
页面查询加载慢,考虑该查询功能是否包含了冗余的处理;
查看对应的sql是否规范,是否添加了索引;
- 索引失效部分情况:
- 表的字符集不同
- 在where条件中进行运算
- like %%,且以通配符开头(‘%abc…’)mysql索引失效会变成全表扫描的操作
- 在索引列上做任何操作(计算、函数、(自动or手动)类型转换),会导致索引失效而转向全表扫描
- 组合索引不满足最左匹配原则
- 两列做比较
- is not null
- not in和not exists等等
小结
本文记载了自己在工作中遇到页面加载时间过长情况,通过代码及sql最后定位到原因索引失效,最终确认列的排序规则不同也会导致索引失效,有点意料之外,记录一下,在实践中会遇到各种奇怪的问题,静下心来,解决方式往往在不起眼的位置。
活动地址:CSDN21天学习挑战赛
边栏推荐
- 623. Add a row to a binary tree: Simple binary tree traversal problems
- How about Ping An Mengwa Card Insurance?Let parents read a few ways to identify products
- Flink Yarn Per Job - 启动TM,向RM注册,RM分配solt
- [7.29-8.5] Review of wonderful technical blog posts in the writing community
- 解决运行文件消失、C盘空间不断缩小而且找不到文件位置的问题
- IPMP、PMP、CPMP三个证书该如何选择,有什么区别,哪个对于工作上的
- Five reasons why developers choose Klocwork, a static analysis tool for code quality, for software security
- 60行从零开始自己动手写FutureTask是什么体验?
- 2022 CCF国际AIOps挑战赛决赛暨AIOps研讨会报名已开启
- A woman is the most beautiful life in the world
猜你喜欢
The training set Loss converges, but the test set Loss oscillates violently?
Go编译原理系列9(函数内联)
再获殊荣 | 赛宁网安入选2022年度“培育独角兽”企业榜单
Support Vector Machine SVM
Visit GOPS Long Zhi booth, Forrester's latest report: "the Forrester Wave: the fourth quarter of 2021 enterprise service management report
Security Issues and Prevention in Web3
Android development with Kotlin programming language II Conditional control
并非富人专属,一文让你对NFT改观
小红的aba子序列(离散化、二分、dp维护区间最短)
STM32H743IIT6学习笔记02——USART
随机推荐
Letter from Silicon Valley: Act fast, Facebook, Quora and other successful "artifacts"!
【7.29-8.5】写作社区精彩技术博文回顾
Apache APISIX Ingress v1.5-rc1 发布
Http-Sumggling Cache Vulnerability Analysis
[7.29-8.5] Review of wonderful technical blog posts in the writing community
没开发人员,接到开发物联网系统的活儿,干不干?
hdu1455 Sticks(搜索+剪枝+剪枝+.....+剪枝)
hdu 1870 愚人节的礼物 (栈)
【HMS core】【FAQ】Health Kit、Ads kit、push Kit典型问题合集5
“蘑菇书”是怎样磨出来的?
nyoj1185最大最小值(线段树)
数据治理体系演进简介
163_技巧_Power BI 一键批量建立自定义字段参数
WingIDE 7.2.0 远程调试
解决 json.dump 报错:TypeError - Object of type xxx is not JSON serializable
前沿技术数字孪生如何应用在智慧城市上?
Android 开发用 Kotlin 编程语言一 基本数据类型
163_Tricks_Power BI one-click batch creation of custom field parameters
机器学习——逻辑回归
Can't get in to ask questions.I want to ask you a question about the return value (traversal of the graph), please give Xiaobai an answer.