当前位置:网站首页>Index optimization principle
Index optimization principle
2022-06-12 19:50:00 【WD Technology】
1、 Full match
Try to use full value matching in query statements .
2、 The left prefix principle
If an index is a composite index , Indexed multiple columns , Follow the left prefix rule , That is, the query starts from the left prefix of the index , You cannot skip the middle column of the index .
3、 Do not operate on index columns
Operations include : Calculation 、 function 、 Automatic or manual type conversion , Do not do any of the above on the index column , Otherwise, the index will be invalidated and the full table scan will be performed
4、 The column index on the right of the range condition is invalid
When the range condition appears in the composite index , Then all column indexes on the right of the range condition are invalid . So when designing and using indexes , The column that frequently performs range queries should be taken as the rightmost column of the index .
**5、 On demand data , To use less select ***
Use less in query select *, otherwise MySQL You need to traverse which fields exist in the result column . meanwhile , Overlay indexes should be used whenever possible , It can avoid looking up the table twice
6、 Avoid using != or <>
In use is not equal to (!= or <>) when , Index not available , Causes a full table scan .
7、 avoid is null or is not null
The index of the query condition that determines the null value is invalid , Causes a full table scan .
8、 avoid like Start with a wildcard
Query criteria like Use wildcards % start , Such as name like ("%abc"), Index failure , Causes a full table scan .
If the business needs to use wildcards % What to do at the beginning ?
The answer is : Use overlay index
9、 To use less or
Use or To connect query criteria , Index failure .
10、 Expand the index as much as possible , Don't create a new index . Let's say it's already in the table a The index of , Now want to add (a,b) The index of , All you need to do is change the original index , Building unnecessary indexes will increase MySQL Space
11、 If you decide how many pieces of data there are , Use limit Limit the ,MySQL When the corresponding number of pieces of data is found , Will stop searching
12、join grammar , Try to put a small watch in front , The need to on Field on , Data types are consistent , And set the corresponding index , otherwise MySQL Cannot use an index to join Inquire about
13、= and in You can order , such as a = 1 and b = 2 and c = 3 establish (a,b,c) Indexes can be in any order ,mysql The query optimizer will help you optimize it into a form that the index can recognize
边栏推荐
- 基于微信电子书阅读小程序毕业设计毕设作品(2)小程序功能
- Negative remainder problem
- How to close icloud when Apple ID of Apple mobile phone forgets password and frequently jumps out to log in
- 【刷题笔记】线段树
- [digital ic/fpga] data accumulation output
- 7:00 tonight | application of PhD debate self supervised learning in Recommendation System
- PostgreSQL database replication - background first-class citizen process walreceiver PG_ stat_ wal_ Receiver view
- Demand and business model innovation - demand 1 - Introduction to demand engineering
- 存储体系概述
- Programming tool download address
猜你喜欢
System log
Low code enables rural construction to open "smart mode"
Shell programming regular expressions and metacharacters
硬件测试之—纹波测试为什么不要使用接地夹子
Microsoft Word 教程,如何在 Word 中插入页眉或页脚?
Promise to solve hell function calls can be used infinitely
Understand Jack Dorsey's web5 from the ppt on page 16
Fault analysis | a case of MySQL remote slave database replication delay
什么是数据驱动
1. Getting to know R
随机推荐
基于微信电子书阅读小程序毕业设计毕设作品(6)开题答辩PPT
How to make a computer installation and startup USB flash disk
腾讯云TDP-virt-viewer win客户端的软件使用
Original publishing practice of pipeline in Jenkins docking with CMDB interface to obtain host list
The component style set by uniapp takes effect in H5 and app, but does not take effect in wechat applet. The problem is solved
Compilation of programs
今晚7:00 | PhD Debate 自监督学习在推荐系统中的应用
基于微信电子书阅读小程序毕业设计毕设作品(8)毕业设计论文模板
基於分布式數據庫本身的定時備份方法
存储体系概述
Microsoft Word tutorial, how to insert page numbers and table of contents in word?
Demand and business model analysis -6- five topics
Wechat e-book reading applet graduation design works (1) development outline
What did 3GPP ran do in the first F2F meeting?
Demand and business model innovation - demand 4- overview of demand acquisition
用户权限和组权限
Efcore tuning
Is it really hopeless to choose electronic engineering and be discouraged?
BigTable (II): how BigTable achieves scalability and high performance
测试必备:推荐一款跨平台App性能专项测试工具!