Explain can help show where the slow down is.  

http://dev.mysql.com/doc/mysql/en/EXPLAIN.html

Indexes on the c1-c5 columns should increase the speed.

>>Explain plan?  Due to the number of records, any indexes I added have
>>significantly delayed the query.
>>
>>-----Original Message-----
>>From: Daniel Clark [mailto:[EMAIL PROTECTED] 
>>Sent: Saturday, June 05, 2004 11:41 AM
>>To: bskolb; [EMAIL PROTECTED]; [EMAIL PROTECTED]
>>Subject: Re: [PHP] DB Query
>>
>>Run an explain plan, but my first quess would be to add indexes to c1, c2,
>>c3, c4, c5 fields.
>>
>>>>I'm trying to optimize a query that in the first example is taking too 
>>>>long to run.
>>>> 
>>>>This is my existing working query:
>>>>$sql = "SELECT count(*) as cnt, id FROM `mYTable` WHERE c1 not in 
>>>>(1,16,36) and c2 not in (1,16,36) and c3 not in (1,16,36) and c4 not 
>>>>in (1,16,36) and
>>>>c5 not in (1,16,36) GROUP BY id";
>>>> 
>>>>Is it possible to do something like this instead (This doesn't work of
>>>>course)
>>>>$sql = "SELECT count(*) as cnt, id FROM  `myTable` WHERE 
>>>>(c1,c2,c3,c4,c5) not in (1,16,36)  GROUP BY id";
>>>> 
>>>>Any other suggestions are appreciated,
>>>> 
>>>>Thanks!
>>>> 
>>>> 
>>>>
>>
>>--
>>PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
>>http://www.php.net/unsub.php
>>
>>-- 
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>


Reply via email to