CREATETABLE`user`(`id`INT(11)NOTNULLAUTO_INCREMENT,`name`VARCHAR(20)DEFAULTNULL,`num`INT(11)DEFAULTNULL,`email`VARCHAR(20)DEFAULTNULL,PRIMARYKEY(`id`),KEY`NewIndex1`(`num`))ENGINE=MYISAMAUTO_INCREMENT=1DEFAULTCHARSET=utf8DESCSELECT*FROM`user`ORDERBYidDESCDESCSELECT*FROM`user`ORDERBYnumDESC#都用不到索引idselect_typetabletypepossible_keyskeykey_lenrefrowsExtra1SIMPLEuserALLNULLNULLNULLNULL40000UsingfilesortDESCSELECT*FROM`user`WHEREnum=23ORDERBYnumDESC#可以用到索引idselect_typetabletypepossible_keyskeykey_lenrefrowsExtra1SIMPLEuserrefNewIndex1NewIndex15const1NULL或者使用innodb引擎也可以在主键排序的时候用到索引这是为什么?
婷婷同学_
千万里不及你
相关分类