当前位置:网站首页>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
边栏推荐
- Jielizhi Bluetooth headset quality control and production skills [chapter]
- 硅谷产品实战学习感触
- Huisheng Huiying 2022 intelligent, fast and simple video editing software
- 【微服务|Sentinel】@SentinelResource详解
- 【小程序】通过scroll-view组件实现左右【滑动】列表
- Depth first search and breadth first search of graph traversal
- What is the mosaic tailgate?
- 字典、哈希表、数组的概念
- notBlank 和 notEmpty
- 13 MySQL-约束
猜你喜欢

from pip._internal.cli.main import main ModuleNotFoundError: No module named ‘pip‘

Stm32f030f4 drives tim1637 nixie tube chip

软件架构的本质

Three development trends of enterprise application from the perspective of the third technological revolution

Redis~02 cache: how to ensure data consistency in MySQL and redis when updating data?

mt管理器测试滑雪大冒险

2022 R1 fast opening pressure vessel operation test questions and answers

MT manager test skiing Adventure

SWT/ANR问题--SWT 导致 kernel fuse deadlock

【小程序】通过scroll-view组件实现左右【滑动】列表
随机推荐
Anomaly-Transformer (ICLR 2022 Spotlight)复现过程及问题
Which securities company is better and which is safer to open a securities account
AirServer最新Win64位个人版投屏软件
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
证券开户选哪个证券公司比较好,哪个更安全
ShanDong Multi-University Training #3
有没有一段代码,让你为人类的智慧所折服
How to display real-time 2D map after rviz is opened
会声会影2022智能、快速、简单的视频剪辑软件
Timer和ScheduledThreadPoolExecutor的区别
from pip._ internal. cli. main import main ModuleNotFoundError: No module named ‘pip‘
Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification
软件架构的本质
STM32F030F4驱动TIM1637数码管芯片
小程序表单校验封装
De PIP. Interne. CLI. Main Import main modulenotfounderror: No module named 'PIP'
mysql binlog的清理
Know --matplotlib
Notes on problems - /usr/bin/perl is needed by mysql-server-5.1.73-1 glibc23.x86_ sixty-four
Understanding threads