当前位置:网站首页>SQL statement simple optimization
SQL statement simple optimization
2022-04-23 05:36:00 【Netfishless】
Summary notes
1、 Avoid using ‘*’, Use column names directly
During parsing , Will ‘*’ Convert to all column names at once , And complete by querying the dictionary , Consume more time .
2、 When querying multiple tables , Try to use table aliases
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-Q2VSZkFk-1650542099215)(https://secure2.wostatic.cn/static/ohQBsP5YJUwjw4XMBSNZtL/image.png)]](/img/24/2df24de28869f4b4623177124a5c07.png)
You can more accurately define which fields of which table , Also avoid the problem of the same column name .
3、Where clause , Put the statement that can quickly narrow the query scope on the far right
because where Statement in clause , It is executed from right to left .

The first “=30” Find , Quickly narrowed the scope , And then “=30” Find... In the scope of “>10” The scope of the .
4、 Use “≥” Instead of “>”

If you use “>3”, The first to find is 3, Then compare them in turn 3 Big data , But the first to find 3 It has no effect on the results .
When using “≥4” when , Will find 4, Then compare them in turn 4 Big data , here 4 Is already one of the right answers
5、 use TRUNCATE Instead of DELETE
DELETE Safe operation , Because it was deleted before , The deleted content will be put into the rollback segment first , If you delete, you can recover .
TRUNCATE Is to delete the data directly , So when it is certain that the data will be deleted , You can use it directly TRUNCATE, Faster execution .
6、 How practical COMMIT
When using COMMIT after , Will release some resources .

7、 Avoid using functions on index columns

When sal Used *2 after ,sal The index on will not take effect , It will still query the whole table .
Reference link
版权声明
本文为[Netfishless]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230530564981.html
边栏推荐
- Isosceles triangle - the 9th Lanqiao provincial competition - group C
- Knowledge of egg testing -- mock, Supertest, coffee
- Data bus realizes the communication between brother components
- Usage and difference of shellexecute, shellexecuteex and winexec in QT
- STL function library
- Traversal array, object parent-child communication props / $emit
- Flutter nouvelle génération de rendu graphique Impeller
- 转置卷积(Transposed Convolution)
- QT drawpixmap and DrawImage blur problem
- Hongji cyclone RPA provides technical support for Guojin securities and realizes process automation in more than 200 business scenarios
猜你喜欢
![[untitled] Notepad content writing area](/img/0a/4a3636025c3e0441f45c99e3c67b67.png)
[untitled] Notepad content writing area

If I am PM's performance, movie VR ticket purchase display

AcWing 836. Merge set (merge set)

转置卷积(Transposed Convolution)

Branch and loop statements

橙单微服务之批量导入

what is wifi6?

Excel 2016 cannot open the file for the first time. Sometimes it is blank and sometimes it is very slow. You have to open it for the second time

Fast application fuzzy search

Intel SGX preliminary learning and understanding notes (continuously updated)
随机推荐
The QT debug version runs normally and the release version runs crash
windows连接mysql出现ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost‘ (10061)
Add two pointers? (legal or illegal)
String class understanding - final is immutable
五一劳动节期间什么理财产品会有收益?
Error handling mechanism of the strongest egg framework in history
创建进程内存管理copy_mm - 进程与线程(九)
相机成像+单应性变换+相机标定+立体校正
Breadth first search topics (BFS)
Some pits used by uni
QT displays the specified position and size of the picture
Fletter next generation graphics renderer impaller
Camera imaging + homography transformation + camera calibration + stereo correction
踩坑:nacos利用startup.cmd -m standalone启动错误
(11) Vscode code formatting configuration
uni使用的一些坑
What financial products will benefit during May Day?
Formal parameters, local variables and local static variables
Pytorch deep learning practice_ 11 convolutional neural network
C, class library