Unnacceptable waitingtime for a left join query. What's wrong?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leif Wessman

    Unnacceptable waitingtime for a left join query. What's wrong?

    Hi!

    Please have a look at the following query:

    SELECT BOOKS.ISBN, BOOKS.TITLE, IMAGES.WEIGHT, IMAGES.WIDTH
    FROM BOOKS
    LEFT JOIN IMAGES ON BOOKS.ISBN = IMAGES.ID
    WHERE MATCH(BOOKS.TIT LE) AGAINST ('mysql database')

    BOOKS.ISBN is primary key and IMAGES.ID is primary key

    This query USUALLY takes less than 1 sec, but SOMETIMES it can take
    about 15 - 25 seconds to complete.

    When I remove the LEFT JOIN part the query ALWAYS is very fast.

    My MySql version is 3.23.53

    When I run EXPLAIN I get the following info:

    +--------+----------+---------------+---------+---------+-----------+------+------------+
    | table | type | possible_keys | key | key_len | ref |
    rows | Extra |
    +--------+----------+---------------+---------+---------+-----------+------+------------+
    | BOOKS | fulltext | NAME | NAME | 0 | |
    1 | where used |
    | IMAGES | eq_ref | PRIMARY | PRIMARY | 10 | BOOKS.ISBN|
    1 | |
    +--------+----------+---------------+---------+---------+-----------+------+------------+

    I've tried to optimize both tables, that didn't help.

    Any ideas of why the query sometimes takes very long time to finish?

    Leif
Working...