Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

            *    #Case 1
            cp.* #Case 2

        FROM crawl_page AS cp
        LEFT JOIN artist AS a
            ON cp.cpURL LIKE CONCAT('%',a.artistPageID,'/',a.artistPageURL,'%')

        WHERE cpPageType = 'SONGS'
            AND cpPageAdded < (
                SELECT cpCrawlDate 
                FROM crawl_page 
                WHERE cpURL = ''

            AND a.artistID IS NULL  

        LIMIT 1

In this query when I use 1st case (selecting everything from both tables) time taken for query is fine about 0.468 sec.

But if I do case 2 (selecting only from main table) it takes hell much time 26 second.

It's not problem just to use case 1, but I can't get the idea how does it work and why?


share|improve this question
Have you tried executing the commands in different orders? (doing case 2 first, for example). MySQL will cache queries, so subsequent queries when the data hasn't changed will be much faster. – GrandmasterB Jan 25 '14 at 22:29
Sure I tried, I do them separately. – George Garchagudashvili Jan 27 '14 at 7:34
I dont see a reason for what you describe. You might want to do an EXPLAIN in mysql to see if there's anything different in the execution of the statement. – GrandmasterB Jan 27 '14 at 22:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.