简单分析MySQL中的primary key功能
在5.1.46中优化器在对primarykey的选择上做了一点改动:
Performance:Whilelookingfortheshortestindexforacoveringindexscan,theoptimizerdidnotconsiderthefullrowlengthforaclusteredprimarykey,asinInnoDB.Secondarycoveringindexeswillnowbepreferred,makingfulltablescanslesslikely。
该版本中增加了find_shortest_key函数,该函数的作用可以认为是选择最小keylength的
索引来满足我们的查询。
该函数是怎么工作的:
Whatfind_shortest_keyshoulddoisthefollowing.Iftheprimarykeyisacoveringindex
andisclustered,likeinMyISAM,thenthebehaviortodayshouldremainthesame.Ifthe
primarykeyisclustered,likeinInnoDB,thenitshouldnotconsiderusingtheprimary
keybecausethenthestorageenginewillhavetoscanthroughmuchmoredata.
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短