当前位置:网站首页>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
边栏推荐
- Watch depth monitoring mode
- After adding qmenu to qtoolbutton and QPushButton, remove the triangle icon in the lower right corner
- Create cells through JS (while loop)
- Flutter nouvelle génération de rendu graphique Impeller
- 五一劳动节期间什么理财产品会有收益?
- 弘玑|数字化时代下,HR如何进行自我变革和组织变革?
- Note: unordered_ Understanding and use of map
- 分支与循环语句
- Edit, cancel, pull up menu
- Generation of straightening body in 3D slicer
猜你喜欢

es6数组的使用

Excel sets row and column colors according to cell contents
![[no title] Click the classification jump page to display the details](/img/a6/fb302129c06e07b8d1eddeaabc9d2d.png)
[no title] Click the classification jump page to display the details
Basic knowledge of redis

Create a tabbar component under the components folder, which is public

On the use of constant pointer and pointer constant -- exercise (record)

Create cells through JS (while loop)

Double click The jar package cannot run the solution

橙单微服务之批量导入

C language - Spoof shutdown applet
随机推荐
On the use of constant pointer and pointer constant -- exercise (record)
五一劳动节期间什么理财产品会有收益?
字符识别easyocr
acwing854. Floyd finds the shortest path
what is wifi6?
Self incrementing sequence creation of MySQL
STD:: String implements split
如果我是pm之 演出电影vr购票展示
世界与个人发展
Find the number of "blocks" in the matrix (BFS)
CMake基础教程(39)pkgconfig
Data bus realizes the communication between brother components
50 SQL exercises, answers and detailed analysis
分支与循环语句
AcWing 836. Merge set (merge set)
可执行程序执行流程
Reading notes of modern methods of C language programming
Relative reference and absolute reference of Excel
deep learning object detection
refused connection