On Feb 7, 2008 1:20 AM, Warren Vail <warren@xxxxxxxxxxxx> wrote: > I did some looking into performance issues many years ago at company that > developed and marketed another database server, comparing the query plan to > the actual code, and a query plan usually shows the processes that consume > the major amount of time, disk I/O, index or table searches and such, but > doesn't show time consumed comparing, discriminating, and totaling, mostly > because they are negligible. > > On the other hand distinct depends on comparison of all columns and will > have no help in reducing row counts unless accompanied by an order by > clause, where as group by implys an orderby and can be faster if indexes are > available for use in row ordering, and while the same totaling occurs, > comparison is limited to the columns specified in the group by. Does DISTINCT really compare all columns? I would think it would only compare the columns explicitly included in the SELECT clause. > The biggest impact on one or the other would be a well placed index, but for > the most part they should be about the same. > > Warren Vail > I have seen discussions where in GROUP BY can be faster than DISTINCT depending on whether the query uses things like correlated subqueries, but this is not applicable in the current case. At any rate, I don't want to stray the conversation any further away than I already have. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php