简单分析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.
热门推荐
7 简短的二胎祝福语
10 简短霸气女儿生日 祝福语
11 祝福语高考小众诗句简短
12 元旦祝福语20秒简短
13 老师过年祝福语大全 简短
14 一生祝福语简短
15 产检祝福语简短霸气
16 朋友店开张祝福语简短
17 生日爱情祝福语大全简短
18 朋友女儿生日祝福语 简短