MySQL Forums
Forum List  »  Newbie

Re: Slow query. Why is it slow?
Posted by: ben jaz
Date: May 26, 2013 01:28AM

Rick James Wrote:
-------------------------------------------------------
> sql.html is nice. What did you use to format it?



Hi Rick;

Thank you for your post. I use http://www.dpriver.com/pp/sqlformat.htm to format sql. And for explain boxes I just copy paste the code for the table :)

Rick I have go t another question for you:

Query # 7 takes 0.0020 seconds; Its here: http://webmoosh.com/sql.html#q7
Query# 9 on the other hand takes 5.5042 sec http://webmoosh.com/sql.html#q9

Why in query 7 Mysql chooses PRIMARY and in query 9 it uses category_index (and the query 9 is slow)? If you look at indexes you see that category_index and class_index both have exact cardinality of 17!

What should I do so I can use exact same query for both cases? Drop category_index? Now I found out that I can FORCE INDEX (PRIMARY) and that way the query takes 0.0003 seconds but that's not right!

Indexes: http://webmoosh.com/indexes.png

Thanks Rick

Options: ReplyQuote


Subject
Written By
Posted
May 19, 2013 06:35AM
Re: Slow query. Why is it slow?
May 26, 2013 01:28AM


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.