is there a join in the sql? Joins can be tricky since the order of the joins can determine the number of records selected from each table. If the joins result in a larger table joining with a smaller table, it could result in more than 30% of the rows being selected and the optimizer will ignore the index. Try moving the order of the records around.

You may even want to split the query into pieces and let the application logic handle the resultsets. I had to do this with a long running query that produced 100 records for export (4+ minutes in a web environment). By splitting the 5 table join into 3 queries and application based arrays, I reduced the run time to about 10 seconds with 50x the output.


From: Eddie Peloke <[EMAIL PROTECTED]>
Reply-To: Eddie Peloke <[EMAIL PROTECTED]>
Subject: [PHP-DB] mysql query plan
Date: Wed, 13 Apr 2005 15:42:41 -0400


We are working to optimize a few queries.  When we run the query with
Explain, it appears that the query optimizer is not using one of the
tables index and doing a full table scan while it appears to use other
tables' indices properly.  We then remove the table with the full
scan, run again with Explain and now the optimizer seems to ignore the
index of one of the other tables when it correctly used that table's
index before in the previous run.  Anyone have some good insight into
how the optimizer picks it's query plan?  It seems to pick one table
and ignore the index for some reason.


PHP Database Mailing List (
To unsubscribe, visit:

-- PHP Database Mailing List ( To unsubscribe, visit:

Reply via email to