select case when createDate 是否需要建立索引? select case when createDate...case whencase whenendfrom a这里createDate 是否需要建立索引?(按照道理一般是在where语句后面加上索引 但是这个判断在前面,所以也要加索引的哦) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select count(distinct id), case when......group byhis explain:+----+-------------+-------+--------+---------------------------------------------+---------+---------+------------------------+--------+---------------------------------+| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |+----+-------------+-------+--------+---------------------------------------------+---------+---------+------------------------+--------+---------------------------------+| 1 | SIMPLE | ul | ALL | idx_SessionLog, idx_Id_lastime | NULL | NULL | NULL | 183498 | Using temporary; Using filesort || 1 | SIMPLE | u | eq_ref | PRIMARY | PRIMARY | 4 | .ul.Id | 1 | Using where; Using index |+----+-------------+-------+--------+---------------------------------------------+---------+---------+------------------------+--------+---------------------------------+2 rows in set 如何让 1 | SIMPLE | ul | ALL | idx_SessionLog, idx_Id_lastime | NULL | NULL | NULL | 183498 | Using temporary; Using filesort 这里能走索引 在select 和 from 之间的表达式是不会用到索引的。 (特例是,你的查询返回字段在索引中都已包含时会直接读索引而不去用数据文件)where , group , order (distinct 类似于 group ) 会利用到索引。 帮忙看一下这个mysql函数,用来返回两个日期之间的年数 MYSQL中float类型奇怪的减法问题 我了个去、安装postgresql出错。事件查看器报如下错误。求解。 mysql导入到sql server mysql乱码,急 mysql中文排序问题 linux 下的mysql.server 和mysqld的区别 mysql里有没有bit类型啊? mysql安装问题求助 如何将count(*)算出的值插入另外一张表专门统计数目的字段 有mysql的备份文件,如何还原数据库? 在已有字符串字段的基础上加唯一标示,该如何啊
....
group byhis explain:
+----+-------------+-------+--------+---------------------------------------------+---------+---------+------------------------+--------+---------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+---------------------------------------------+---------+---------+------------------------+--------+---------------------------------+
| 1 | SIMPLE | ul | ALL | idx_SessionLog, idx_Id_lastime | NULL | NULL | NULL | 183498 | Using temporary; Using filesort |
| 1 | SIMPLE | u | eq_ref | PRIMARY | PRIMARY | 4 | .ul.Id | 1 | Using where; Using index |
+----+-------------+-------+--------+---------------------------------------------+---------+---------+------------------------+--------+---------------------------------+
2 rows in set 如何让
1 | SIMPLE | ul | ALL | idx_SessionLog, idx_Id_lastime | NULL | NULL | NULL | 183498 | Using temporary; Using filesort
这里能走索引