当前位置:网站首页>SQL optimization
SQL optimization
2022-07-01 23:30:00 【Jingling cat】
limit Optimize
once SQL Analysis of query optimization principle (900W+ data , from 17s To 300ms)
There's a financial statement , Not divided into databases and tables , The current amount of data is 9555695, Paging query uses limit, Query time before optimization 16 s 938 ms (execution: 16 s 831 ms, fetching: 107 ms), Adjust as follows SQL after , Time consuming 347 ms (execution: 163 ms, fetching: 184 ms);
operation : The query criteria are placed in the subquery , Subqueries only look up primary keys ID, Then use the primary key Association determined in the subquery to query other attribute fields ;
principle : Reduce the return operation , Use delay association or subquery to optimize the super multi page scenario .
-- Before optimization SQL
SELECT Various fields
FROM `table_name`
WHERE Various conditions
LIMIT 0,10;
-- After optimization SQL
SELECT Various fields
FROM `table_name` main_tale
RIGHT JOIN
(
SELECT Subqueries only look up primary keys
FROM `table_name`
WHERE Various conditions
LIMIT 0,10;
) temp_table ON temp_table. Primary key = main_table. Primary key
边栏推荐
- What is mosaic?
- ShanDong Multi-University Training #3
- Applet form verification encapsulation
- 硅谷产品实战学习感触
- 2022 R1 fast opening pressure vessel operation test questions and answers
- Redis data types and application scenarios
- The difference between timer and scheduledthreadpoolexecutor
- Experience of practical learning of Silicon Valley products
- Redis~02 cache: how to ensure data consistency in MySQL and redis when updating data?
- What category does the Internet of things application technology major belong to
猜你喜欢

神经网络物联网的发展趋势和未来方向
![[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing](/img/08/9ecfd53a04e147022dde3449aec132.png)
[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing

问题随记 —— file /usr/share/mysql/charsets/README from install of MySQL-server-5.1.73-1.glibc23.x86_64 c

Istio, ebpf and rsocket Broker: in depth study of service grid

Redis 主从同步

Zhongang Mining: it has inherent advantages to develop the characteristic chemical industry dominated by fluorine chemical industry

RPA: Bank digitalization, business process automation "a small step", and loan review efficiency "a big step"

Win 10 mstsc connect RemoteApp

物联网开发零基础教程

软件架构的本质
随机推荐
Matplotlib常用图表
物联网开发零基础教程
What category does the Internet of things application technology major belong to
问题随记 —— file /usr/share/mysql/charsets/README from install of MySQL-server-5.1.73-1.glibc23.x86_64 c
Redis RDB快照
flutter Unable to load asset: assets/images/888. png
MySQL -- convert rownum in Oracle to MySQL
MySQL binlog cleanup
Typescript enumeration
[swoole Series 1] what will you learn in the world of swoole?
Openresty load balancing
CKS CKA ckad change terminal to remote desktop
内存泄露和内存溢出的区别是什么?
Redis数据类型和应用场景
Applet form verification encapsulation
Commemorate becoming the first dayus200 tripartite demo contributor
2022-07-01: at the annual meeting of a company, everyone is going to play a game of giving bonuses. There are a total of N employees. Each employee has construction points and trouble points. They nee
每日三题 6.30(2)
CADD课程学习(3)-- 靶点药物相互作用
想请教股票开户要认识谁?在线开户是安全么?