MySQL Forums
Forum List  »  Performance

Re: greatest-n-per-group performace for different data types
Posted by: Thomas Wiedmann
Date: December 13, 2010 05:57AM

Hi Martin,

it seems that your Query didn't match the EXPLAIN result. Where is the table "emoWeather"?
Please compute EXPLAIN with..

mysql>EXPLAIN SELECT ...

One hint...add some ".. ORDER BY NULL" to your Sub-Query. Look at this..
    SELECT customers.customerID, Count( customers.emotionID ) / C.totalPeople * 100.0 AS emotionPercent 
    FROM `customers` 
    INNER JOIN 
    
        (SELECT customers.customerID, Count( customers.emotionID ) AS totalPeople
        FROM `customers` 
        GROUP BY customers.customerID
        ORDER BY NULL) C 
    
    ON customers.customerID = C.customerID 
    WHERE customers.emotionID = 0 
    GROUP BY customers.customerID 
    ORDER BY emotionPercent DESC 
    LIMIT 0,6

with kind regards,
Thomas

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: greatest-n-per-group performace for different data types
942
December 13, 2010 05:57AM


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.