group by 效率
时间: 2023-08-22 11:07:35 浏览: 95
回答: 在语义相同,有索引的情况下,group by和distinct的效率是相同的,因为它们都能使用索引来进行优化。然而,在语义相同,无索引的情况下,distinct的效率要高于group by。这是因为distinct和group by都需要进行分组操作,但是group by可能会触发排序操作,导致SQL执行效率降低。因此,如果在无索引的情况下需要进行数据去重,使用distinct会更高效。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* [MySQL中的 distinct 和 group by 效率比较](https://blog.csdn.net/qq_38323053/article/details/128703275)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
- *2* [MySQL中,distinct 和 group by 哪个效率更高?](https://blog.csdn.net/m0_71777195/article/details/129635720)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
- *3* [distinct效率更高还是group by效率更高?](https://blog.csdn.net/weixin_42615847/article/details/118342524)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文