当前位置:网站首页>sql 使用到where和groupby时到底怎么建立索引?
sql 使用到where和groupby时到底怎么建立索引?
2022-08-11 01:26:00 【CSDN问答】
优化sql的时候,由于数据量比较大,一个简单的sql但执行速度特别慢
SELECT max( id ) FROM log WHERE create_date <= "2022-08-03" GROUP BY code
尝试过多种情况,create_date、code、(code,create_date)、(create_date,code),使用(code,create_date)组合索引最快只需要1秒,使用explain命令查看索引的两列都用到了,其他需要10秒左右
据网上查到的资料可以建立(create_date,code)索引,毕竟先where再groupby ,然而使用explain可以看到实际只使用到组合索引中的create_date
为什么(code,create_date)是最快的,这到底是什么原理
边栏推荐
- Pico 4更多参数曝光:Pancake+彩色透视,还有Pro版本
- Dual machine thermal for comprehensive experiment (VRRP + OSPF + + NAT + DHCP + VTP PVSTP + single-arm routing)
- 什么是数组
- 【C语言】探索数据的存储(整形篇)
- BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection Paper Notes
- 池化技术有多牛?来,告诉你阿里的Druid为啥如此牛逼!
- sed of the Three Musketeers of Shell Programming
- 导入数据包上传宝贝提示“类目不能为空”是什么原因,怎么解决?
- How to build speed, speed up again
- #yyds干货盘点#【愚公系列】2022年08月 Go教学课程 008-数据类型之整型
猜你喜欢
C # - delegate detailed usage
BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection 论文笔记
Distributed. Performance optimization
postgresql parameter meaning
异常和异常处理机制
什么是“门”电路(电子硬件)
MSTP——多生成树(案列+配置)
Jvm. Profiling tools (jconsole, jvisualvm, arthas, jprofiler, mat)
Web APIs BOM - A Comprehensive Case of Operating Browsers
Mysql数据库安装配置详细教程
随机推荐
Two-dimensional array combat project -------- "Minesweeper Game"
数据分析面试手册《SQL篇》
【ASM】字节码操作 ClassWriter COMPUTE_FRAMES 的作用 与 visitMaxs 的关系
Successfully resolved TypeError: can't multiply sequence by non-int of type 'float'
数据分析面试手册《统计篇》
Still using Xshell?You are out, recommend a more modern terminal connection tool, easy to use!
时间戳转换为日期格式、获取当前时间戳
Dual machine thermal for comprehensive experiment (VRRP + OSPF + + NAT + DHCP + VTP PVSTP + single-arm routing)
How to check if the online query suddenly slows down
R语言多元线性回归、ARIMA分析美国不同候选人对经济GDP时间序列影响
微信小程序自定义navigationBar
Data Analysis Interview Manual "SQL"
apache+PHP+MySQL+word press,安装word press时页面报错?
Jvm. Profiling tools (jconsole, jvisualvm, arthas, jprofiler, mat)
Linux安装redis数据库
微信小程序通过URL Scheme动态的渲染数据
微信小程序获取当前页面的url和参数
How to determine the size of the version number
Sigma development pays attention to details
如何防止离职员工把企业文件拷贝带走?法律+技术,4步走