简单分析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 官宣新年祝福语简短