简单分析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 公司过年祝福语简短优美