MySQL Forums
Forum List  »  Performance

Re: Terrible performance of a specific query with lots of connections
Posted by: Rick James
Date: September 09, 2009 08:32PM

How much RAM do you have?
| innodb_buffer_pool_size | 21474836480 |
That is 21GB, I hope you have at least 24GB of RAM!

Before:
EXPLAIN 
SELECT  dr.referenced_document_id
    FROM  document_references dr
    JOIN  profile_documents pd ON (pd.document_id = dr.document_id)
    WHERE  pd.profile_id = '23890'
      AND  dr.referenced_document_id NOT IN (
                 SELECT  document_id
                   FROM  profile_documents
                   WHERE  profile_id = '23890'):

Turn the NOT IN ( SELECT) into a LEFT JOIN, something like:
EXPLAIN 
SELECT  dr.referenced_document_id
    FROM  document_references dr
    JOIN      profile_documents pd ON (pd.document_id = dr.document_id)
    LEFT JOIN profile_documents pd2
               ON pd2.document_id = dr.referenced_document_id
    WHERE   pd.profile_id = '23890'
      AND  pd2.profile_id = '23890'
      AND  pd2.document_id IS NULL

Options: ReplyQuote




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.