MySQL中distinct与group by之间的性能进行比较

2019-01-04 20:03:33王冬梅

加了索引之后 distinct 比没加索引的distinct 快了107倍。
加了索引之后 group by 比没加索引的group by 快了43倍。
再来对比 :distinct 和group by
不管是加不加索引group by 都比distinct 快。

因此使用的时候建议选 group by。

以上就是在MySQL中distinct与group by之间的性能进行比较的,通过以上比较是不是对distinct和group by有了更深入的了解,希望对大家的学习有所帮助。

您可能感兴趣的文章:

MySQL中distinct与group by语句的一些比较及用法讲解MySQL中distinct语句的基本原理及其与group by的比较MySQL中索引优化distinct语句及distinct的多字段操作MySQL中distinct语句去查询重复记录及相关的性能讨论MySQL中Distinct和Group By语句的基本使用教程MySQL中distinct和count(*)的使用方法比较分析MySQL中优化distinct的技巧解析mysql中:单表distinct、多表group by查询去除重复记录使用distinct在mysql中查询多条不重复记录值的解决办法MySQL关键字Distinct的详细介绍