Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL fastest 'GROUP BY' script

Is there any difference in how I edit the GROUP BY command?

my code:

SELECT Number, Id 
    FROM Table
    WHERE(....)
    GROUP BY Id, Number

is it faster if i edit it like this:

 SELECT Number, Id 
    FROM Table
    WHERE(....)
    GROUP BY Number , Id
like image 442
nionios Avatar asked Jul 15 '13 09:07

nionios


1 Answers

it's better to use DISTINCT if you don't want to aggregate data. Otherwise, there is no difference between the two queries you provided, it'll produce the same query plan

like image 53
jazzytomato Avatar answered Oct 07 '22 05:10

jazzytomato