levyta Posted March 28, 2012 Share Posted March 28, 2012 I have the following query: INSERT ignore INTO `table3` (`id`) SELECT table1.id FROM table1 JOIN table2 ON table1.id = table2.id WHERE … ORDER BY table1.date DESC LIMIT 400 Does anyone know a way how to fasten the query? Quote Link to comment https://forums.phpfreaks.com/topic/259896-accelerate-a-query/ Share on other sites More sharing options...
requinix Posted March 28, 2012 Share Posted March 28, 2012 Hmm... Strap it down? Buckle it in? Quick question: What's table3 for? Quote Link to comment https://forums.phpfreaks.com/topic/259896-accelerate-a-query/#findComment-1332067 Share on other sites More sharing options...
The Little Guy Posted March 28, 2012 Share Posted March 28, 2012 First do an explain on the select portion of your query: EXPLAIN SELECT table1.id FROM table1 JOIN table2 ON table1.id = table2.id WHERE … ORDER BY table1.date DESC LIMIT 400 is it using any indexes? No? Add some. (probably on columns table1.id and table2.id) Quote Link to comment https://forums.phpfreaks.com/topic/259896-accelerate-a-query/#findComment-1332077 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.