Mysql index 'and' 总是选择第一个创建的索引?
Mysql index 'and' chooses index that was created first always?
https://dev.mysql.com/doc/internals/en/optimizer-and-relations.html
文章说,如果两个条件都被索引并且具有相同的连接类型,它会使用最先创建的索引。
如果一个索引具有更高的基数,那么选择该索引作为驱动程序不是更好吗?它不应该查询存储引擎吗?
如果我不了解基数,我是否应该在这些情况下强制索引?
我想知道这个文档是否已经过时了。毕竟,该描述似乎使 analyze table
的用处大大减少。那就是 documented 作为:
MySQL uses the stored key distribution to decide the order in which
tables should be joined when you perform a join on something other
than a constant. In addition, key distributions can be used when
deciding which indexes to use for a specific table within a query.
此描述与内部文档中的文档特别矛盾。
或者,也许这个参考文献写得不好,适用于没有其他密钥分发信息可用的情况。正如您所说,使用具有 更高 基数的索引可能是一个更好的起点。
此外,如文档本身所述,"join type" 的使用描述不当。这真的应该被称为 "comparison type",或类似的东西。
https://dev.mysql.com/doc/internals/en/optimizer-and-relations.html
文章说,如果两个条件都被索引并且具有相同的连接类型,它会使用最先创建的索引。
如果一个索引具有更高的基数,那么选择该索引作为驱动程序不是更好吗?它不应该查询存储引擎吗?
如果我不了解基数,我是否应该在这些情况下强制索引?
我想知道这个文档是否已经过时了。毕竟,该描述似乎使 analyze table
的用处大大减少。那就是 documented 作为:
MySQL uses the stored key distribution to decide the order in which tables should be joined when you perform a join on something other than a constant. In addition, key distributions can be used when deciding which indexes to use for a specific table within a query.
此描述与内部文档中的文档特别矛盾。
或者,也许这个参考文献写得不好,适用于没有其他密钥分发信息可用的情况。正如您所说,使用具有 更高 基数的索引可能是一个更好的起点。
此外,如文档本身所述,"join type" 的使用描述不当。这真的应该被称为 "comparison type",或类似的东西。