gpt4 book ai didi

MySql 按使用索引分组

转载 作者:行者123 更新时间:2023-11-29 06:07:03 24 4
gpt4 key购买 nike

如果我在 Mysql 中有一个表,它在字段上有一个多列索引(phone_numbername)

在查询此表时,如果我只是对 phone_number 进行分组,是否会使用此索引?

如果我执行任何仅涉及 phone_number 的操作,是否会使用索引?

如果我想group by phone_number, name 那么会使用这个索引吗?

最佳答案

在某些情况下,MySQL 能够使用索引访问执行 GROUP BY。

the preconditions for using indexes for GROUP BY are that all GROUP BY columns reference attributes from the same index, and that the index stores its keys in order.

这意味着在你的情况下你的问题都可以使用索引

您可以在这里找到更多信息 http://dev.mysql.com/doc/refman/5.7/en/group-by-optimization.html

关于MySql 按使用索引分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40852852/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com