Thread: Slow Queries
View Single Post

   
  #7 (permalink)  
Old 04-24-2008, 07:08 PM
D Hill
 
Posts: n/a
Default Re: Slow Queries

On Thu, 24 Apr 2008 at 10:16 -0400, perrin@elem.com confabulated:

> On Thu, Apr 24, 2008 at 2:54 AM, Sebastian Mendel
> <lists@sebastianmendel.de> wrote:
>> IMHO not in this case, cause it is just a simple "WHERE field IN ()"

>
> I'm pretty sure that just looks like a bunch of ORs to MySQL. If it
> didn't use the index with OR, it won't use it with IN.
>
> What usually works is to change it to UNION:
>
> SELECT wite_what, wite_desc FROM witelist
> WHERE wite_what = '$oct1'
> UNION
> SELECT wite_what, wite_desc FROM witelist
> WHERE wite_what = '$oct1.$oct2'
> UNION
> ...etc.


I'm still new to MySQL. The input is greatly appreciated.

It took some minor thought and the documentation, but I understand what is
going on with the UNION.
Reply With Quote