??????ν????????????mysql??ν????Щ???????????????????????????????????????????????????????????????????????????????????????mysql????????????? BTREE?????BTREE??????????????Σ????????20??????δ???BTREE??????2^20?е?????????????????????????????????????????о???????????;
????Explain?????????
????EXPLAIN??????????????????SQL????explain?????mysql????????????????select????????????????????????????????д??????????????.
??????÷???????select????????Explain???????
????Explain select * from blog where false;
????mysql??????????????????????????SQL???з?????????????????????????????????????select * from blog where falseMysql???????в????????????????SQL?????????????MySQL?????????????κ??????????;
????Example
????mysql> EXPLAIN SELECT `birday` FROM `user` WHERE `birthday` < "1990/2/2";
????-- ?????
????id: 1
????select_type: SIMPLE -- ?????????????????????????????
????table: user -- ???????е????????????????
????type: range -- ????????????С??1990/2/2?????????)????????????У?????????????????????????????????????system > const > eq_ref > ref > fulltext > ref_or_null > index_merge > unique_subquery > index_subquery > range > index > ALL??const??????????У?ALL?????????????????????????????????????????range?????????ref??
????possible_keys: birthday  -- ???MySQL??????????????????????С???????????????????????????????????????????WHERE?????????????Щ??Σ?????????β???????????? 
????key: birthday -- ???????????????????NULL????????????????????primary???????????????????
????key_len: 4 -- ???????????????????NULL????????NULL??????????????????£???????????
????ref: const -- ????????λ?????key?????á? 
????rows: 1 -- ????????mysql???????????????????????innodb??????????
????Extra: Using where; Using index -- ???????????????????????????????Using temporary??Using
????select_type
????simple ??select(?????union??????)
????primary ?????select
????union union?е???????????select???
????dependent union union?е???????????select???????????????
????union result union??????
????subquery ?????е?????select
????dependent subquery ?????е?????select??????????????
????derived ???????select(from????????)
????Extra??type??????
????Distinct:???MYSQL????????????????????У???????????
????Not exists: MYSQL?????LEFT JOIN???????????????LEFT JOIN??????У???????????
????Range checked for each Record(index map:#):????????????????????????????????????????????MYSQL???????????????????????????з????С????????????????????????
????Using filesort: ??????????????????????? ??MYSQL??????ж???????????????ζ?????????????????????????????洢?????????????????????е?????????????????
????Using index: ??????????????????????е????????ж???????ж????????????????????????????ж????????????????????
????Using temporary ??????????????????????? ??????MYSQL??????????????????洢??????????????????????м?????ORDER BY?????????GROUP BY??
????Where used ?????WHERE???????????Щ?н?????????????????????????????????????е?????У?????????????ALL??index????????????????????????????????????(????Ч????????????
????system ???????У?system???????const????????????????
????const:???е???????????????????????(????????????????Ω?????)??????????У??????????????????MYSQL??????????????????????????
????eq_ref:???????У?MYSQL???????????????У?????????????????????ж????????????????????????????????Ω????????????
????ref:??????????????????????????Ω??????????????????Щ????????(???磬?????????)??????????????????????????????????????????ж???????????????????????????????????????—??????+
????range:???????????????????????????Χ?е??У????????>??<?????????????????+
????index: ??????????????????е?????????????????????(??ALL???????????????С???????)+
????ALL:?????????????????????????????????????裬????????????t???????
????????type:
?????????Only index??????ζ???????????????е????????????????????????????
?????????where used???????????where?????
?????????impossible where ????ò???where????????????????
???????????????Using filesort????Using temporary???????????WHERE??ORDER BY????????????????????????WHERE????????????????ORDER BY????????????Using filesort????????????????????????????????????????
????????
??????????????
????UNIQUE????
???????????????????????????NULL?
????INDEX???????
????????????????????????
????PRIMARY KEY????????
???????????????????????????NULL????????????????primary_key????
????fulltext index ???????
????????????????????????е???????????????????????????????е????????????????????е??????? ?????????????????????myisam??????????????Ч??????????????????????coreseek??xunsearch??????????????????????
??????????CURD
?????????????
????ALTER TABLE
?????????????????????????
????ALTER TABLE ???? ADD ???????? (unique??primary key??fulltext??index)[??????](?????)
????ALTER TABLE `table_name` ADD INDEX `index_name` (`column_list`) -- ???????????????;???????????????????????????;
????ALTER TABLE `table_name` ADD UNIQUE (`column_list`)
????ALTER TABLE `table_name` ADD PRIMARY KEY (`column_list`)
????ALTER TABLE `table_name` ADD FULLTEXT KEY (`column_list`)
????CREATE INDEX
????CREATE INDEX?????????????????UNIQUE????
????--????????????????????;
????CREATE INDEX index_name ON table_name (column_list)
????CREATE UNIQUE INDEX index_name ON table_name (column_list)
???????????????????????
????CREATE TABLE `test1` (
????`id` smallint(5) UNSIGNED AUTO_INCREMENT NOT NULL?? -- ??????洴?????????????????????????
????`username` varchar(64) NOT NULL COMMENT '?????'??
????`nickname` varchar(50) NOT NULL COMMENT '???/????'??
????`intro` text??
????PRIMARY KEY (`id`)?? 
????UNIQUE KEY `unique1` (`username`)?? -- ???????????????????????????????
????KEY `index1` (`nickname`)??
????FULLTEXT KEY `intro` (`intro`)
????) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='????????';
?????????????
????DROP INDEX `index_name` ON `talbe_name` 
????ALTER TABLE `table_name` DROP INDEX `index_name`
????-- ?????????????????????table_name?е?????index_name;
????ALTER TABLE `table_name` DROP PRIMARY KEY -- ??????????????????????????????????????
???????????
????show index from tablename G;
?????????????
?????????????????????????
?????????????????
????1.??????д???????
???????????? ?????? ???????????????????????????
????????????д???8??????a ??b ??c??d??a??b??c??d??????????4
????????????д???????????????????????????????????
??????????????в??????????????????????
????2.?? where??on??group by??order by ?г?????????????
????3.???С?????????????????????????????????С???????????????????????????
????4.????????????????????
????5.??????????????????????????????????????DML???????????????????????????ε???????????
????6.????????????????????????????С??????????????????????????
???????????????????
??????????????????????????????????????????????????;