Optimize "not in" query
        Posted  
        
            by Vasu
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Vasu
        
        
        
        Published on 2010-06-07T05:28:37Z
        Indexed on 
            2010/06/07
            5:32 UTC
        
        
        Read the original article
        Hit count: 301
        
Please help optimize this query:
SELECT ts.SiteId, COUNT(ts.SiteId) AS Count 
FROM ts 
WHERE ts.SiteId not in 
   (SELECT ts.SiteId FROM ts WHERE ts.uniqueid = 'xxx') 
GROUP BY ts.SiteId ORDER BY Count DESC
        © Stack Overflow or respective owner