当前位置:网站首页>MySQL optimization
MySQL optimization
2022-07-27 00:10:00 【Cheng Cheng, it's Xiaobai】
Catalog
MySQL Three aspects of optimization :
answer :1. Database design 2. System usage 3. System bottlenecks
3. The bottleneck of the system
This article is my previous notes , If I saw it on the Nuggets, it's right , I'm Cheng Cheng : Cheng Cheng My personal homepage - dynamic - Nuggets This is the only one . If there is anything wrong, you are welcome to point out the problem , I am a little white .
The link of the last article is :MySQL Note down _ Cheng Cheng is Xiaobai's blog -CSDN Blog . This article is about optimization
If it is springboot If so, please see springboot Create project _ Cheng Cheng is Xiaobai's blog -CSDN Blog , This is from scratch, not finished springboot, Study together !!!!
MySQL Three aspects of optimization :
answer :1. Database design 2. System usage 3. System bottlenecks
1. Database design
Try to make the database smaller and take up disk space .
1). Use smaller integer types when possible .(mediumint Just like int More appropriate ).
2). Define as many fields as possible not null, Unless this field needs null.
3). If you don't use variable length fields, for example varchar, Then use a fixed size record format, such as char.
4). The primary index of the table should be as short as possible . In this way, each record has a name tag and is more efficient .
5). Create only the indexes you really need . The index is good for retrieving records , But it's not good for keeping records quickly . If you always have to search in the combined fields of a table , So create an index on these fields . The first part of the index must be the most frequently used field . If you always need to use a lot of fields , First, you should copy more of these fields , Better compression of indexes .
6). All data has to be processed before it is saved to the database .
7). All fields have to have default values .
8). In some cases , It's much faster to divide a frequently scanned table into two . When scanning a dynamic format table to get relevant records , It may use a smaller static format table, especially if .
2. The purpose of the system
1). Try to use long connections .
2).explain complex SQL sentence .
3). If two related tables are to be compared , The fields to be compared must be of the same type and length .
4).LIMIT Try to follow order by perhaps distinct. You can avoid doing it once full table scan.
5). If you want to clear all records of the table , Suggest using truncate table tablename instead of delete from tablename.
6). Be able to use STORE PROCEDURE perhaps USER FUNCTION When .
7). In one insert Multiple record insertion format is used in the statement . And use load data infile To import a lot of data , It's more than just indert Much faster .
8). often OPTIMIZE TABLE To clean up the pieces .
9). And that is date If you want to make a comparison frequently, try to save it in unsigned int Faster type .
3. The bottleneck of the system
1). Disk search .
Parallel search , Separate data into multiple disks , This will speed up the search time .
2). Disk read and write (IO)
Data can be read from multiple media in parallel .
3).CPU cycle
The data is stored in the main memory . So you have to add CPU To process the data .
4). Memory bandwidth
When CPU To store more data in CPU From the cache , The bandwidth of memory becomes the bottleneck .
This article is my previous notes , If I saw it on the Nuggets, it's right , I'm Cheng Cheng : Cheng Cheng My personal homepage - dynamic - Nuggets This is the only one . If there is anything wrong, you are welcome to point out the problem , I am a little white .
The link of the last article is :MySQL Note down _ Cheng Cheng is Xiaobai's blog -CSDN Blog . This article is about optimization
If it is springboot If so, please see springboot Create project _ Cheng Cheng is Xiaobai's blog -CSDN Blog , This is from scratch, not finished springboot, Study together !!!!
边栏推荐
- 2022.7.18-----leetcode.749
- Section 6: introduction to cmake grammar
- 【面试:并发篇26:多线程:两阶段终止模式】volatile版本
- Practice of data storage scheme in distributed system
- In depth interpretation of the investment logic of the consortium's participation in the privatization of Twitter
- 百度网址收录
- 文件上传到服务器
- C language array
- 文件上传到OSS文件服务器
- Azure Synapse Analytics 性能优化指南(4)——使用结果集缓存优化性能
猜你喜欢

Skiasharp's WPF self drawn bouncing ball (case version)

NFT展示指南:如何展示你的NFT藏品

查看 Anaconda 创建环境的位置

Add an article ----- scanf usage

Pytorch学习记录(二):张量

Share a regular expression

Opencv camera calibration and distortion correction
![Embedded system migration [8] - device tree and root file system migration](/img/af/5b5d38522f0cc434bdafbf892936ee.png)
Embedded system migration [8] - device tree and root file system migration

DHCP, VLAN, NAT, large comprehensive experiment

Baidu website Collection
随机推荐
Baidu website Collection
When aw9523b chip is used to drive 16 channel led, the LED is wrongly lit
PTA 7-1 play with binary tree
2022.7.18-----leetcode.749
会议OA项目排座功能以及送审功能
Halloween treatments (drawer principle)
[netding Cup 2018] Fakebook records
【C语言】数组
Identity server4 authorization successful page Jump encountered an error: exception: correlation failed Solution of unknown location
[interview: concurrent Article 27: multithreading: hesitation mode]
Simple SQL optimization
The NFT market pattern has not changed. Can okaleido set off a new round of waves?
2022.7.26-----leetcode.1206
Part II - C language improvement_ 9. Linked list
JUnit、JMockit、Mockito、PowerMockito
PTA 7-4 small generation (DFS)
Method of realizing program startup and self startup through registry
Iptables prevent nmap scanning and binlog
09_ Keyboard events
Chapter 2 develop user traffic interceptors
