From experiments, I founded that the GROUP BY is 10+ times faster than DISTINCT. They are different. So what I learned is: GROUP-BY is anyway not worse than DISTINCT, and it is better sometimes.

Is distinct faster than GROUP BY?

DISTINCT is used to filter unique records out of all records in the table. It removes the duplicate rows. SELECT DISTINCT will always be the same, or faster than a GROUP BY.

Does GROUP BY affect performance?

Despite what MSDN documentation says, no, it doesn’t matter for GROUP BY queries. it does make a difference and it does produce different execution plans (and different result sets of course). It still uses the index though, at least in that SQL-Fiddle test.

Should I use GROUP BY or distinct?

If you want to group your results, use GROUP BY, if you just want a unique list of a specific column, use DISTINCT.

Which is faster distinct or GROUP BY in Teradata?

So in worst case DISTINCT was 2.5x slower than GROUP BY, but GROUP BY was 44x faster than DISTINCT. locally) is always more efficient! Within Teradata a subquery spool is automatically distinct (unless the optimizer knows it’s unique, e.g.

Does distinct reduce performance?

Yes, as using DISTINCT will (sometimes according to a comment) cause results to be ordered. Sorting hundreds of records takes time. Try GROUP BY all your columns, it can sometimes lead the query optimiser to choose a more efficient algorithm (at least with Oracle I noticed significant performance gain).

Why distinct is slower than GROUP BY?

Group by is expensive than Distinct since Group by does a sort on the result while distinct avoids it. But if you want to make group by yield the same result as distinct give order by null .. It seems that the queries are not exactly the same.

What is the difference between unique and distinct?

The main difference between unique and distinct is that UNIQUE is a constraint that is used on the input of data and ensures data integrity. While DISTINCT keyword is used when we want to query our results or in other words, output the data.

Does distinct affect performance?

Yes, basically it has to sort the results and then re-processed to eliminate the duplicates. This cull could also be being done during the sort, but we can only speculate as to how exactly the code works in the background. You could try and improve the performance by creating an index composed of all three (3) fields.

How does GROUP BY work in Teradata?

Teradata Group By clause makes the group of related rows. The group by clause identifies the rows which have the same value for the specified attribute (i.e, duplicate value) and returns a single row of information instead of all the rows where the attribute has the same value.