**
download:移动端架构师**【完结】**
**
**
移动端普通工程师到架构师的全方位蜕变
全面掌握面向移动端未来的主流技术栈
从零开始亲自构建千万级电商项目,串联移动架构师成长各阶段
**
函數操作對條件字段做函數操作走不了索引。select * from t1 where date(c) ='2019-05-21';
優化:改成範圍查询select * from t1 where c>='2019-05-21 00:00:00' and c<='2019-05-21 23:59:59';
隱式轉換操作符與不同類型的操作對象一同運用時,就會發作類型轉換以使操作兼容。select user_name,tele_phone from user_info where tele_phone =11111111111; /* tele_phone varchar */
實践會做函數操作:select user_name,tele_phone from user_info where cast(tele_phone as singed int) =11111111111;
優化:類型統一select user_name,tele_phone from user_info where tele_phone ='11111111111';
含糊查询通配符在前面select * from t1 where a like '%1111%';
優化:含糊查询必需包含條件字段前面的值select * from t1 where a like '1111%';
範圍查询範圍查询數據量太多,需求回表,因而不走索引。select * from t1 where b>=1 and b <=2000;
優化:降低單次查询範圍,分屢次查询。(實践可能速度沒得快太多,倡議走索引)select * from t1 where b>=1 and b <=1000;
show profiles;
+----------+------------+------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+------------------------------------------+
| 1 | 0.00534775 | select * from t1 where b>=1 and b <=1000 |
| 2 | 0.00605625 | select * from t1 where b>=1 and b <=2000 |
+----------+------------+------------------------------------------+
2 rows in set, 1 warning (0.00 sec)
計算操作即便是简單的計算explain select * from t1 where b-1 =1000;
優化:將計算操作放在等號後面explain select * from t1 where b =1000 + 1;