简单分析MySQL中的primary key功能
在5.1.46中优化器在对primary key的选择上做了一点改动:Performance: While looking for the shortest index for a covering index scan, the optimizer did not consider the full row length for a clustered primary key, as in InnoDB. Secondary covering indexes will now be preferred, making full table scans less likely。该版本中增加了find_shortest_key函数,该函数的作用可以认为是选择最小key length的索引来满足我们的查询。该函数是怎么工作的:调用Primary_key_is_clustered(),当返回值为true,执行find_shortest_key:选择key length最小的覆盖索引,然后来满足查询。
用户评论