MySQL Forums
Forum List  »  Performance

Re: Slow SELECT on two tables
Posted by: Rick James
Date: March 01, 2009 09:23PM

First to explain what I see...

* You have two InnoDB tables, each with only about 15K rows, and each being only a few MB in size.

* You are joining on a secondary key (filehash) and the SELECT is scanning one table, then reaching into the other table once per row.

* Normally, I would grumble about the wildcard at the beginning of a LIKE, but this is a case where it would not use an index anyway.

* You might be expecting 15K results? If you expecting only a few results, then the changed 'AND', below, might help.

I would not be surprised if it took a few seconds. But 40s ??

Perhaps innodb_buffer_pool_size is very low? It should be about 70% of _available_ RAM.

I doubt if it would help, but please try changing
AND webfiles.filepath LIKE CONCAT('%/', product_files.filename);
to
AND SUBSTRING_INDEX(webfiles.filepath, '/', -1) = product_files.filename;


If it is too small, you may be thrashing the disk. Do you have any metrics on CPU and disk usage during this query?

Options: ReplyQuote


Subject
Views
Written By
Posted
4605
March 01, 2009 04:26PM
Re: Slow SELECT on two tables
2051
March 01, 2009 09:23PM
2132
March 02, 2009 05:02PM
1954
March 02, 2009 09:14PM


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.