MySQL Forums
Forum List  »  Optimizer & Parser

Re: Optimize subquery, replace IN() with JOIN
Posted by: Rick James
Date: November 17, 2016 08:11PM

See if the comes closer to working:

    SELECT  a.id, a.title, a.alias
        FROM  content AS a
        WHERE  a.id =1842
          AND  EXISTS
        (
            SELECT  *
                FROM  category_content_se
                WHERE  content_id = a.id
                  AND  content_typ = 'actual' 
        )
        ORDER BY  a.date_add DESC
        LIMIT  10;

Indexes:
    content: INDEX(id, date) -- in this order
    category_content_se: INDEX(content_id, content_typ) -- in either order

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Optimize subquery, replace IN() with JOIN
969
November 17, 2016 08:11PM


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.