Java全棧工程師

download:Java全棧工程師

半年時間,帶你從後端走向全棧
從後端到全棧CTO,我花了10年,這10年濃縮成了120多個小時,個人10年,你或許只須要半年,我但願
你比我幸運,少一些投石問路式的摸索,以更快的速度成爲能勝任更高職位,更受市場青睞的全棧工程師
函數操做
對條件字段作函數操做走不了索引。html

select * from t1 where date© =‘2019-05-21’;
優化:改爲範圍查詢後端

select * from t1 where c>=‘2019-05-21 00:00:00’ and c<=‘2019-05-21 23:59:59’;
隱式轉換
操做符與不一樣類型的操做對象一同運用時,就會發做類型轉換以使操做兼容。ide

select user_name,tele_phone from user_info where tele_phone =11111111111; / tele_phone varchar /
實踐會作函數操做:htm

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’;
含糊查詢
通配符在前面get

select * from t1 where a like ‘%1111%’;
優化:含糊查詢必需包含條件字段前面的值it

select * from t1 where a like ‘1111%’;
範圍查詢
範圍查詢數據量太多,需求回表,於是不走索引。io

select * from t1 where b>=1 and b <=2000;
優化:下降單次查詢範圍,分屢次查詢。(實踐可能速度沒得快太多,倡議走索引)ast

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)
計算操做
即使是簡單的計算class

explain select * from t1 where b-1 =1000;
優化:將計算操做放在等號後面

explain select * from t1 where b =1000 + 1;

相關文章
相關標籤/搜索