List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:March 21 1999 7:40pm
Subject:Re: how to optimize
View as plain text  
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
Thread
how to optimizekalle volkov21 Mar
  • Re: how to optimizeAyman Haidar21 Mar
    • Re: how to optimizeThimble Smith21 Mar
  • how to optimizeMichael Widenius21 Mar
Re: how to optimizeFred Lindberg21 Mar