On Sun, Mar 21, 1999 at 11:25:38AM -0500, Ayman Haidar wrote:
> Thus spake kalle volkov (kalle@stripped):
> > SELECT SUBSTRING_INDEX(ip,'.',-1) AS temp, count(ip) AS howmany FROM
> > MyDatabase GROUP BY temp ORDER BY howmany DESC LIMIT 10;
>
> I am no expert, but shouldn't you use some indexes, may be on ip.
The problem is that you can't use an index on ip, because the
SUBSTRING_INDEX(...) function still has to be called for every
row in the table. I suppose it would be slightly better (i.e.,
MySQL could use the index file instead of a full table search)
but you'd still have to go through every single row.
Tim