I had a problem with ordering when combining multiple tables containing millions of data. But I got a solution, instead of joining with the excellent use of EXISTS, will improve performance on the following issue.
How to improve performance order with joins in mysql
SELECT `tracked_twitter` . *, COUNT( * ) AS twitterContentCount, retweet_count + favourite_count + reply_count AS engagement FROM `tracked_twitter` INNER JOIN `twitter_content` ON `tracked_twitter`.`id` = `twitter_content`.`tracked_twitter_id` INNER JOIN `tracker_twitter_content` ON `twitter_content`.`id` = `tracker_twitter_content`.`twitter_content_id` WHERE `tracker_twitter_content`.`tracker_id` = '88' GROUP BY `tracked_twitter`.`id` ORDER BY twitterContentCount DESC LIMIT 20 OFFSET 0
But this method solves if I only need a result set from the parent table. What if I want to perform grouped calculations and other math functions other than the parent table. I wrote a query that solves my criteria, but it takes 20 seconds to complete. How can I optimize it?
Thank you in advance
source share