Re: PHP/mySQL question about groups

From: Date: Thu, 07 Feb 2008 04:40:46 +0000
Subject: Re: PHP/mySQL question about groups
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-268837@lists.php.net to get a copy of this message
On Feb 6, 2008 11:20 PM, Nathan Nobbe <quickshiftin@gmail.com> wrote: > On Feb 6, 2008 10:59 PM, Andrew Ballard <aballard@gmail.com> wrote: > > > Of course, in this case you could just avoid all the confusion with > > this statement as well: > > > > SELECT DISTINCT name, size > > FROM wine > > im not sure why, but i think distinct is typically way slower than group by. > > -nathan > I can't really say for MySQL, but in my experience I'd say "it depends." It seems to me that for this case they should be about the same, as it's always been my thinking that GROUP BY did a DISTINCT implicitly. However, I don't really know the internals of any DB platform so I can't confirm that. I ran DESCRIBE on a couple different tables, and they both return the same plan. I don't see any notable difference in the queries either. However, I'll leave it to the OP to test and see if one is better for his question. Andrew

« previous php.general (#268837) next »