explain select * from table; 使用explain命令調查最終查詢計劃,但是sql陳述句不執行
create table cityex like city 只會獲取到city這個表的表結構,其中的內容無法同步獲取到放在新表cityex里面
insert into cityex select * from city
不光會獲取到city這個表的表結構,其中的內容也會同步獲取到放在新表cityex里面
create table cityex as select * from city; 創建表的同時,把資料填進去,
洗掉索引
alter table `config` drop index idx_config_name;
運算式不走索引
函式不走索引
不等于不走索引
explain select * from cityex where ID - 1 =276;
mysql中的UPPER(s)函式是用來把小寫的字符轉換成大寫
explain select * from cityex where UPPER(name) = 'HEFEI';
explain select * from cityex where name != 'HE';
樓下也為不等于
explain select * from cityex where name <> 'he';
樓下為in的時候就走索引
explain select * from cityex where name not in ('HE','ge');
改為‘h%’就走索引
explain select * from cityex where name like '%h';
新建索引,之后以新建索引來掃描,而不是全盤掃碼
新建索引
alter table table1 add index idx_population(population,name);
查看是什么掃描
explain select population,name from table1 order by population desc;
alter table table1 add index idx_CountryCode_pop_name(countrycode,population,name);
建索引要遵循最左原則,也就是從where后面的條件開始設定他的一組索引中的第一個索引
explain select population,name from table1 where countrycode = 'CHINA' order by population desc;
個性簽名:一個人在年輕的時候浪費自己的才華與天賦是一件非常可惜的事情
如果覺得這篇文章對你有小小的幫助的話,記得在左下角點個“👍”哦,博主在此感謝!
萬水千山總是情,打賞5毛買辣條行不行,所以如果你心情還比較高興,也是可以掃碼打賞博主,哈哈哈(っ??ω??)っ???!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/78641.html
標籤:其他
上一篇:在buildroot中添加驅動
