MySQL Forums
Forum List  »  Optimizer & Parser

Re: Searching for a user across two tables taking 23 seconds
Posted by: Marek Podmaka
Date: March 12, 2008 09:49AM

I think the main problem is:
status like '%active%'
This can't use any indexes. What are the possible values of field status? If it is either 'active' or 'inactive', then you should use status = 'active' and it would use index on this field. But even better is to use status as tinyint (or char(1)) and have values of 0/1.

Try to read manual about the EXPLAIN, it is very useful. Look at the column with rows produced. For your query, it should read 3000 rows from one of the tables and 1 row from another table (= for each row from 1st). 3000*1=3000 rows total which get produced and needs to be analyzed.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Searching for a user across two tables taking 23 seconds
2191
March 12, 2008 09:49AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.