JonnoTheDev Posted August 9, 2010 Author Share Posted August 9, 2010 good point 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 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. 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] 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. 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. 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. Link to comment https://forums.phpfreaks.com/topic/209894-slow-query/page/2/#findComment-1097662 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.