JonnoTheDev Posted August 9, 2010 Author Share Posted August 9, 2010 good point Quote Link to comment https://forums.phpfreaks.com/topic/209894-slow-query/page/2/#findComment-1097174 Share on other sites More sharing options...
JonnoTheDev Posted August 10, 2010 Author Share Posted August 10, 2010 This query is slightly faster SELECT u.siteId FROM user u WHERE userId NOT IN(SELECT userId FROM submission WHERE bookmarkUrl ='http://www.xyz.com' AND scriptId=4) AND u.scriptId=4 GROUP BY u.siteId Quote Link to comment https://forums.phpfreaks.com/topic/209894-slow-query/page/2/#findComment-1097461 Share on other sites More sharing options...
fenway Posted August 10, 2010 Share Posted August 10, 2010 Please post EXPLAIN output again. Quote Link to comment https://forums.phpfreaks.com/topic/209894-slow-query/page/2/#findComment-1097553 Share on other sites More sharing options...
JonnoTheDev Posted August 10, 2010 Author Share Posted August 10, 2010 Attached [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/209894-slow-query/page/2/#findComment-1097565 Share on other sites More sharing options...
fenway Posted August 10, 2010 Share Posted August 10, 2010 Again, drop the group by for a minute -- and dependent subquery is the problem. Use a LEFT JOIN ... is NULL instead. Quote Link to comment https://forums.phpfreaks.com/topic/209894-slow-query/page/2/#findComment-1097645 Share on other sites More sharing options...
JonnoTheDev Posted August 10, 2010 Author Share Posted August 10, 2010 Use a LEFT JOIN ... is NULL instead. Sorry, lost me there a bit matey. Are you going back to the original query on the first page of this post. Quote Link to comment https://forums.phpfreaks.com/topic/209894-slow-query/page/2/#findComment-1097649 Share on other sites More sharing options...
fenway Posted August 10, 2010 Share Posted August 10, 2010 Sorry, I thought it said correlated, not dependent -- though I do prefer the LEFT JOIN over NOT IN(). But no, not to the original query, just to the one you recently posted. Add an index on ( scriptID, siteID ) and see how it performs -- drop the other one, of course. Quote Link to comment https://forums.phpfreaks.com/topic/209894-slow-query/page/2/#findComment-1097662 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.