对某字段进行去重时,在该字段不加索引和加索引的比较
加了索引之后 distinct 比没加索引的 distinct 快了 107倍。
加了索引之后 group by 比没加索引的 group by 快了 43倍。
不管是加不加索引 group by 都比 distinct 快。因此使用的时候建议选 group by
对某字段进行去重时,在该字段不加索引和加索引的比较
加了索引之后 distinct 比没加索引的 distinct 快了 107倍。
加了索引之后 group by 比没加索引的 group by 快了 43倍。
不管是加不加索引 group by 都比 distinct 快。因此使用的时候建议选 group by