In performance wise distinct is good or group by is good?
eg:select name from emp group by name;
select distinct name from emp;

Answer Posted / ghorban adabi

I have test DISTINCT and GROUP BY query on a table in my
site db with 7800 record. the results that turned GROUP BY
was faster than DISTINCT!!!
GROUP BY result -> Query took 0.0094 sec
DISTINCT result -> Query took 0.0133 sec

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of subquery?

549


What is the cartesian product of the table?

552


How do you make a trace?

588


Characterize join and name diverse sorts of joins?

533


1.what are diff types of joins , and explain diff between cross join and full outer join 2.diff types of views 3. Diff types of index 4. What is diff b/w stores procedure and function procedure 5.diff between double and int in SQL 6.diff between char and varchar in SQL. 7.Oracle or SQL whice you will preferred and why.

1097






After removing a table from database, what other related objects have to be dropped explicitly?

557


How to use subqueries with the in operators in ms sql server?

568


Do you know what is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure?

544


Hi all, can any one please tell me the difference between sql server 2008 and orace 9i

1529


Explain the types of indexes.

643


What are dml triggers and types of dml triggers?

553


Tell me what is difference between view and materialized view?

523


How do I find the sql server version?

524


What is a trigger and its types?

540


What are the different types of stored procedures?

556