当前位置:网站首页>Brief description of SQL optimization problems
Brief description of SQL optimization problems
2022-07-06 18:15:00 【Programming for Hongmeng】
SQL Optimization of the 7 In terms of
- Create index
- Avoid index invalidation
- Lock granularity ( Row lock or watch lock )
- Paging query optimization
- Avoid querying all fields
- analysis SQL Implementation plan of
- show profile analysis SQL Execution performance
Create index
- It is forbidden to create a separate index for each column in a table
- Every Innodb Table must have a primary key
- Pay attention to the field order of the combined index
- Override index first
- Avoid using foreign key constraints
Avoid index invalidation ( Failure scenario )
- With % At the beginning LIKE Inquire about
- Operations on index columns , function upper() etc. ,or、!=、<>、not in wait
- Composite index created , But the query conditions are not satisfied “ The leftmost match ” principle
- Use... In query conditions or, And or There is no condition in the index before and after , Then the indexes involved will not be used
Lock granularity ( Row lock still Table locks )
- MySQL Our storage engines fall into two broad categories : MyISAM and InnoDB
- MyISAM Only supported Table locks
- InnoDB Support Row lock and Table locks
- update operation when , In order to ensure the accuracy of table data , Usually Lock , In order to improve the high concurrency of the system , We usually recommend Row lock , Reduce lock conflicts 、 Lock wait time . therefore , Storage engines usually choose InnoDB
Paging query optimization
Avoid querying all fields
analysis SQL Implementation plan of
show profile analysis SQL Execution performance
The follow-up will gradually improve ... Make a point in this chapter first
边栏推荐
猜你喜欢
C语言指针*p++、*(p++)、*++p、*(++p)、(*p)++、++(*p)对比实例
Interesting - questions about undefined
Pytest learning ----- detailed explanation of the request for interface automation test
SQL statement optimization, order by desc speed optimization
Jerry's updated equipment resource document [chapter]
模板于泛型编程之declval
1700C - Helping the Nature
Prophet模型的简介以及案例分析
李书福为何要亲自挂帅造手机?
30 minutes to understand PCA principal component analysis
随机推荐
從交互模型中蒸餾知識!中科大&美團提出VIRT,兼具雙塔模型的效率和交互模型的性能,在文本匹配上實現性能和效率的平衡!...
FMT open source self driving instrument | FMT middleware: a high real-time distributed log module Mlog
VR panoramic wedding helps couples record romantic and beautiful scenes
UDP protocol: simple because of good nature, it is inevitable to encounter "city can play"
趣-关于undefined的问题
《ASP.NET Core 6框架揭秘》样章发布[200页/5章]
What is the reason why the video cannot be played normally after the easycvr access device turns on the audio?
FMT开源自驾仪 | FMT中间件:一种高实时的分布式日志模块Mlog
Pytest learning ----- pytest operation mode and pre post packaging of interface automation testing
从交互模型中蒸馏知识!中科大&美团提出VIRT,兼具双塔模型的效率和交互模型的性能,在文本匹配上实现性能和效率的平衡!...
Comparative examples of C language pointers *p++, * (p++), * ++p, * (++p), (*p) + +, +(*p)
Getting started with pytest ----- test case rules
Today in history: the mother of Google was born; Two Turing Award pioneers born on the same day
带你穿越古罗马,元宇宙巴士来啦 #Invisible Cities
二分(整数二分、实数二分)
MS-TCT:Inria&SBU提出用于动作检测的多尺度时间Transformer,效果SOTA!已开源!(CVPR2022)...
High precision operation
Interview shock 62: what are the precautions for group by?
Transport layer congestion control - slow start and congestion avoidance, fast retransmission, fast recovery
Kill -9 system call used by PID to kill process