当前位置:网站首页>Several index utilization of joint index ABC
Several index utilization of joint index ABC
2022-07-07 06:49:00 【Adong-007】
For composite indexes :Mysql Use the fields in the index from left to right , A query can use only a part of the index , But only the far left part . For example, the index is key index (a,b,c). Can support a | a,b| a,b,c 3 Combination of search , But does not support b,c Search for . When the leftmost field is a constant reference , The index is very efficient .
Here are some examples :
(1) select * from myTest where a=3 and b=5 and c=4; ---- abc The order
abc All three indexes are in where It's used in the conditions , And it all worked
(2) select * from myTest where c=4 and b=6 and a=3;
where The order of the conditions inside will be changed before the query mysql Automatic optimization , The effect is the same as the sentence
(3) select * from myTest where a=3 and c=7;
a Use index ,b of no avail , therefore c There is no index effect (b Not used , So the index cannot reach c , therefore c Unused index )
(4) select * from myTest where a=3 and b>7 and c=3; ---- b Range value , The breakpoint , blocked c The index of
a Yes ,b Also used. ,c Not used , This place b It's the range value , It's also a breakpoint , It just uses the index itself
(5) select * from myTest where b=3 and c=4; — Federated indexes must be used sequentially , And need to use it all
because a The index is not used , So here bc No indexing effect
(6) select * from myTest where a>4 and b=7 and c=9;
a Yes b Not used ,c Not used (a The range is used, so , Equivalent to a breakpoint , After that b,c No index is used )
(7) select * from myTest where a=3 order by b;
a Index is used ,b Index effect is also used in result sorting ,a In any of the following paragraphs b It's in order
(8) select * from myTest where a=3 order by c;
a Index is used , But this place c No ranking effect , Because there's a break in the middle , Use explain You can see filesort
(9) select * from mytable where b=3 order by a;
b No index is used , Sorting a It doesn't have an indexing effect
The following conditions will invalidate the index :
1. Do nothing on the index column ( Calculation 、 function 、( Automatically or Manual ) Type conversion ), It will cause index invalidation and turn to full table scan
2. The storage engine cannot use the column to the right of the index range condition ( for example Only for b , c)
3. Try to use overlay index ( Queries that only access the index ( The index column is consistent with the query column )), Reduce select ***
4.mysql In use is not equal to (!= perhaps <>) When ** Failure to use the index will result in a full table scan
5.is null,is not null You can't use indexes
6.ike Start with a wildcard (’%abc…’)mysql Index invalidation will become a full table scan operation . problem : solve like‘% character string %’ When index is not used7. String index is invalid without single quotation marks
Suggest :
- For single key indexes , Try to choose the current query Better filtering index
- When choosing a composite index , At present Query The most filterable field in the index field order , The higher the position, the better .
- When choosing a composite index , Try to include the current query Medium where Index of more fields in clause
- When choosing a composite index , Try to include the current query Medium where Index of more fields in clause
- By analyzing statistics and adjusting as much as possible query To achieve the purpose of selecting the appropriate index
边栏推荐
- 拼多多败诉:“砍价免费拿”侵犯知情权但不构成欺诈,被判赔400元
- Prompt for channel security on the super-v / device defender side when installing vmmare
- 字符串常量与字符串对象分配内存时的区别
- LM11丨重构K线构建择时交易策略
- Haqi projection Black Horse posture, avec seulement six mois de forte pénétration du marché des projecteurs de 1000 yuans!
- Redhat5 installing vmware tools under virtual machine
- 微信小程序隐藏video标签的进度条组件
- 隐马尔科夫模型(HMM)学习笔记
- MySQL (x)
- ESXI挂载移动(机械)硬盘详细教程
猜你喜欢
MATLAB小技巧(29)多项式拟合 plotfit
Learning notes | data Xiaobai uses dataease to make a large data screen
ICML 2022 | explore the best architecture and training method of language model
毕业设计游戏商城
LM small programmable controller software (based on CoDeSys) Note 23: conversion of relative coordinates of servo motor operation (stepping motor) to absolute coordinates
Abnova 膜蛋白脂蛋白体技术及类别展示
How to install swoole under window
品牌·咨询标准化
RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`问题解决
FlexRay通信协议概述
随机推荐
算法---比特位计数(Kotlin)
途家、木鸟、美团……民宿暑期战事将起
多学科融合
品牌电商如何逆势增长?在这里预见未来!
dolphinscheduler3. X local startup
MySQL installation
快速定量,Abbkine 蛋白质定量试剂盒BCA法来了!
DB2获取表信息异常:Caused by: com.ibm.db2.jcc.am.SqlException: [jcc][t4][1065][12306][4.25.13]
[solution] final app status- undefined, exitcode- 16
怎样查找某个外文期刊的文献?
使用net core优势/为什么使用
企業如何進行數據治理?分享數據治理4個方面的經驗總結
Common problems of caching in high concurrency scenarios
Leite smart home longhaiqi: from professional dimming to full house intelligence, 20 years of focus on professional achievements
Redhat5 installing vmware tools under virtual machine
[GNN] graphic gnn:a gender Introduction (including video)
微信小程序隐藏video标签的进度条组件
博士申请 | 上海交通大学自然科学研究院洪亮教授招收深度学习方向博士生
精准时空行程流调系统—基于UWB超高精度定位系统
二十岁的我4面拿到字节跳动offer,至今不敢相信