当前位置:网站首页>Advanced learning of MySQL -- Application -- Optimization of other SQL statements
Advanced learning of MySQL -- Application -- Optimization of other SQL statements
2022-06-27 17:32:00 【Magic pig 9898】
Optimization when inserting data
Batch insert
Once inserted 500 To 1000 It is more appropriate , It is not recommended to insert more than 1000 pieces at a time .
If you want to insert tens of thousands of pieces ?
It can be , Split into multiple SQL sentence :
It is recommended to commit transactions manually
When multiple insert statements , It is recommended to start the transaction first , Commit multiple insert statements as one transaction .
It is recommended to insert the primary key in sequence
The primary key is out of order , The performance is much better .
Mass insert data
For example, , There is a business to insert millions , Tens of millions of data records .
At this time to use insert The performance of is too low , You can use MySQL Database provides load Insert instructions , The operation is as follows :
On the left is the original disk file structure , On the right is load Watch after coming in
explain , Files that conform to certain rules , Not necessarily a comma , Colon when possible , wait
demonstration :
When the client connects to the server , Add parameters --local-infile -u root -pmysql --local-infile -u root -p
Set global parameters local_infile by 1, Turn on the switch to import data from the local load file set global local_infile = 1;
perform load The instruction will prepare the data , Load into table structure load data local infile '/root/sql1.log' into table 'tb_user' fields terminated by ',' lines terminated by '\n';
Primary key optimization
How data is organized
stay InnoDb In the storage engine , Table data is organized and stored according to the primary key sequence , The tables in this way of storage are called index organization tables .
For clustered indexes , What is stored below is , Table row data .
If the primary key is inserted out of order , Page splitting may occur
If there is page splitting, there is page merging


Key design principles

order by Optimize
group by Optimize
limit Optimize
count Optimize
update Optimize
边栏推荐
- Redis installation
- d3dx9_ How to repair 33.dll? d3dx9_ What if 33.dll is lost?
- Use pyinstaller to package py files into exe. Precautions and error typeerror:_ get_ sysconfigdata_ name() missing 1...‘ check_ Solutions to exists'
- Dark horse programmer - software testing foundation class -02-30-45 tools open browser running code, audio, video, test points, audio and video labels, layout labels. Advanced hyperlink syntax, absolu
- Sliding window + monotone queue concept and example (p1886 Logu)
- Offline disk group
- How to write a resume?
- Data center table reports realize customized statistics, overtime leave summary record sharing
- (5) SPI application design and simulation verification 1 - logic sorting
- Electronic smart package tutorial
猜你喜欢

阿里云刘珅孜:云游戏带来的启发——端上创新

EMQ helps Qingdao Yanbo build a smart water platform

【牛客刷题】NowCoder号称自己已经记住了1-100000之间所有的斐波那契数。 为了考验他,我们随便出一个数n,让他说出第n个斐波那契数。如果第n个斐波那契大于6位则只取后6位。

All you want to know about large screen visualization is here

Cesium realizes satellite orbit detour

d3dx9_ How to repair 33.dll? d3dx9_ What if 33.dll is lost?

Common optimization techniques for Web Performance

Oracle concept II
#yyds干货盘点#简述chromeV8引擎垃圾回收

d3dx9_ How to repair 40.dll? Win10 system d3dx9_ What if 40.dll is lost?
随机推荐
Generate zip package command
Hospital reservation and registration system - system structure
Detailed explanation of various GPIO input and output modes (push-pull, open drain, quasi bidirectional port)
The European unified charging specification act was passed before the end of the year, and it is planned to expand to products such as laptop and keyboard
Some details of Huawei OSPF
C语言教师工作量管理系统
Leetcode 46 Full Permutation
wheel ui
LeetCode 124. Binary tree maximum path sum - binary tree series question 8
National food safety risk assessment center: do not blindly and unilaterally pursue "zero addition" and "pure natural" food
医院预约挂号系统-系统结构
Ping An technology's practice of migrating from Oracle to ubisql
Defiato is an innovation that combines user-friendly features of a centralized platform with defi services
Delete duplicate elements in the sorting linked list
Use pyinstaller to package py files into exe. Precautions and error typeerror:_ get_ sysconfigdata_ name() missing 1...‘ check_ Solutions to exists'
Software testing Basics - software testing history, process, classification, benefits, limitations
Leetcode 704. Binary search
Etcd visualization tool: kstone deployment (I), rapid deployment based on Helm
Oracle概念三
d3dx9_ How to repair 40.dll? Win10 system d3dx9_ What if 40.dll is lost?