当前位置:网站首页>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
边栏推荐
- C language - Spoof shutdown applet
- Multi process model in egg -- egg document Porter
- Hongji | how does HR carry out self change and organizational change in the digital era?
- Uncle wolf is looking for a translator -- Plato -- ongoing translation
- Branch and loop statements
- [triangle Yang Hui triangle printing odd even cycle JS for break cycle]
- MySQL创建oracle练习表
- Vscode settings JSON configuration
- selenium預先加載cookie的必要性
- After adding qmenu to qtoolbutton and QPushButton, remove the triangle icon in the lower right corner
猜你喜欢

Some pits used by uni

相机成像+单应性变换+相机标定+立体校正

Deep learning object detection

Flutter nouvelle génération de rendu graphique Impeller

Excel sets row and column colors according to cell contents

The 8th Blue Bridge Cup 2017 - frog jumping cup

After NPM was upgraded, there was a lot of panic

Excel 2016 打开文件第一次打不开,有时空白,有时很慢要打开第二次才行

C# ,类库

mysql中duplicate key update
随机推荐
AcWing 836. Merge set (merge set)
Fast application fuzzy search
STD:: String implements split
selenium预先加载cookie的必要性
Note: unordered_ Understanding and use of map
QT compressed folder
Pytorch deep learning practice_ 11 convolutional neural network
Watch depth monitoring mode
Hongji | how does HR carry out self change and organizational change in the digital era?
Frequently asked interview questions - 3 (operating system)
Use of qwbengneview and qwebchannel.
转置卷积(Transposed Convolution)
Phlli in a VM node
Flutter 新一代圖形渲染器 Impeller
Linear sieve method (prime sieve)
OSI层常用协议
Why can't V-IF and V-for be used together
Establish excel bookkeeping book through setting context menu
Flutter nouvelle génération de rendu graphique Impeller
Create process memory management copy_ Mm - processes and threads (IX)