当前位置:网站首页>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)是最快的,这到底是什么原理
边栏推荐
- 循环单词
- C# JObject解析JSON数据
- sed of the Three Musketeers of Shell Programming
- QT+VTK+PCL拟合圆柱并计算起始点、中止点
- postgresql参数意义
- 成功解决raise TypeError(‘Unexpected feature_names type‘)TypeError: Unexpected feature_names type
- Use mysql statement to operate data table (table)
- @Autowired注入RedisCache报错空指针
- 【HFSS学习记录1】实例:宽带非对称多节定向耦合器设计
- WinForm (5) control and its members
猜你喜欢

【ASM】字节码操作 ClassWriter COMPUTE_FRAMES 的作用 与 visitMaxs 的关系

阿里的数据同步神器——Canal

WebView2 通过 PuppeteerSharp 实现RPA获取壁纸 (案例版)
![[Server data recovery] Data recovery case of lvm information and VXFS file system corruption caused by raid5 crash](/img/dc/043f861507fc16530446bf051941ef.jpg)
[Server data recovery] Data recovery case of lvm information and VXFS file system corruption caused by raid5 crash

二维数组实战项目--------《扫雷游戏》

什么是“门”电路(电子硬件)

Some Experiences of Embedded Software Logging

apache+PHP+MySQL+word press,安装word press时页面报错?

【开源】壁纸软件,给自己电脑设计专属特效

Volatile和CAS
随机推荐
如何做到构建的提速,再提速
#yyds Dry Goods Inventory#[Yugong Series] August 2022 Go Teaching Course 008-Integer of Data Types
BEVDepth: Acquisition of Reliable Depth for Multi-view 3D Object Detection Paper Notes
两日总结九
22、库存服务
数据分析面试手册《SQL篇》
还在用 Xshell?你 out 了,推荐一个更现代的终端连接工具,好用到爆!
what is an array
J9数字论:DAO治理更像一种生态过程:治理原生于网络,不断演变
The concept of services
Exceptions and exception handling mechanisms
std::format格式化自定义类型
Linux安装redis数据库
Ambari迁移Spark2到其它机器(图文教程)
WinForm(五)控件和它的成员
apache+PHP+MySQL+word press, page error when installing word press?
微信小程序强制更新版本
什么是数组
Sigma development pays attention to details
容器技术真的是环境管理的救星吗?