当前位置:网站首页>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
边栏推荐
- Solving Poisson equation by tensorflow
- C语言教师工作量管理系统
- leetcode 69. Square root of X
- Oracle concept II
- After the mobile phone, it was reported that Samsung also cut the output of TV and other home appliance product lines
- C language teacher workload management system
- 2/14 preliminary calculation geometry
- Determine the maximum number of specific words in a string
- leetcode 200. Number of islands
- 1. introduction to MariaDB
猜你喜欢

09 route guard authenticates URL

树莓派初步使用

All you want to know about large screen visualization is here

leetcode 92. Reverse linked list II

leetcode 200. Number of islands

数组表示若干个区间的集合,请你合并所有重叠的区间,并返回 一个不重叠的区间数组,该数组需恰好覆盖输入中的所有区间 。【LeetCodeHot100】

Leetcode 33. Search rotation sort array

Oracle concept II

Halcon: discrete digital OCR recognition

Leetcode 46 Full Permutation
随机推荐
Why should string be designed to be immutable?
Oracle concept II
[qt learning notes]qt uses MFC compilation to generate DLL libraries. The problem that DLL cannot be loaded occurs on computers without programming environment
ROS "topic" programming implementation
Adaoracle supports multi chain distributed Oracle with wide area node quotation
Unity shadow shadow pancaking
[Niuke's questions] nowcoder claims to have remembered all Fibonacci numbers between 1 and 100000. To test him, we gave him a random number N and asked him to say the nth Fibonacci number. If the nth
10 minutes to master the installation steps of MySQL
leetcode 142. Circular linked list II
Community sharing jumpserver in the eyes of senior open source users: a fortress machine for "Crazy" iteration
Kubernetes basic self-study series | introduction to ingress API
Special function calculator
07. Express routing
A large number of missing anchor text
Handwritten promise series - all
电子智慧套装教程
关于#mysql#的问题:问题遇到的现象和发生背景
10分钟掌握mysql的安装步骤
Software testing learning - dark horse programmer, software testing learning outline
About how vs2019c # establishes the login interface, the user name and password entered must match the records in the access database