当前位置:网站首页>What is slow query? How to optimize?
What is slow query? How to optimize?
2022-07-16 06:06:00 【Kuo-Teng】
What is slow query ? How to optimize ?
1. What is slow query ?
The slow query , seeing the name of a thing one thinks of its function , It's a slow query , So what is a slow query ? Different companies have different definitions of slow query .
In general , We took the inquiry time longer than 1s The query of is called slow query .
2. Optimize SQL To reduce slow queries
2.1. Index optimization
Many slow queries are due to SQL It is caused by not following the appropriate index . however , Even with the index , If not used correctly ,SQL The statement will still not go to the index when executing . In which cases SQL Statements do not go through the index ?
WHEREIn the condition of1=1, The query condition is always true , May lead toWHERECondition invalidation , Perform a full table query ;- Using functions or implicit conversions will result in no indexing ;
LIKEMatch when the wildcard symbol is in front , Don't walk index ;- Negative conditions are used ;
OROne of them has an index , Another situation without ;- Multi column indexes need to meet the leftmost matching principle ;
- The character sets or codes of the two tables are different , When querying the associated table ;
INToo much content , It's not going to be indexed ;
2.2 Disassembly batch
If the amount of data is large , You can try to disassemble batches to reduce slow queries :
- Multi level nested query is changed to multiple query ;
INSubqueries affect query performance , useJOINWay to replace ;- The number of queries is too large , Split into multiple queries 、 assemble .
- Reverse query used ( such as
NOT IN) perhapsINToo many statement parameter sets , This may cause a full table scan , In this case, try to split the statement , Or filter in memory ; - take ⼤ Field 、 Fields with low access frequency are split into separate tables to store , Separate hot and cold data ;
- Sub database and sub table ;
- file ;
边栏推荐
- autoreleasepool问题汇总
- Unity experiment - control the movement of game objects
- Notes 2 of network communication security
- 将字符串转为时间晚了5天,避坑指南
- Compilation principle - parser design
- 图形图像编程实践 课程报告
- unity实验-模拟太阳系星体运动
- ES6 -- symbol() and map()
- Get the set of parent node IDs from top to bottom
- JS -- built in function of data system
猜你喜欢

Summer precipitation Web Learning -- PHP Foundation

Intranet penetration notes --:) a smiling face

Notes on network communication security -- OSPF theory and experiment

Notes 2 of network communication security

SNMP started

密态数字经济:用密码去“深海淘珍珠”

Arthas简介及IDEA插件快速入门

摩斯隐私计算一体机全项通过深圳国金测评中心83项测评

DVA data flow

开源实习 | Compiler SIG 实习任务正式发布,欢迎报名申请!
随机推荐
MySQL-约束
autoreleasepool问题汇总
unity实验-重力撞墙
Ergodic summary
[BJDCTF2020]Cookie is so stable
基础设施 NFTScan 正式发布 Solana 网络 NFT 浏览器
Moss privacy computing all-in-one machine has passed 83 evaluations of Shenzhen Guojin evaluation center
网络通信安全部分笔记二
ES6--Set
Network security emergency response terminal detection and response technology
Analysis, capture and simulation attack of Sniffer Pro on ARP Protocol
PHP docking wechat payment native TP5 framework
計算LocalDate之間的天數差,方便快捷
Web API——获取元素、事件基础
41.js -- closure
Nftscan Developer Platform launches Multi Chain NFT data pro API service
编译原理-词法分析器设计
内网渗透笔记——msf
Intranet penetration notes - Registry self startup and MSI rights lifting
Compilation principle - parser design