What possibilities are there to optimize the situation?
SELECT b.`id` FROM ( SELECT action.`id`, action.`entityId`, action.`entityType`, action.`pluginKey`, action.`data`, activity.timeStamp FROM db1_tblprefix1_newsfeed_action action INNER JOIN db1_tblprefix1_newsfeed_activity activity ON action.id = activity.actionId INNER JOIN `db1_tblprefix1_newsfeed_action_set` cactivity ON action.id = cactivity.actionId INNER JOIN `db1_tblprefix1_base_user` base_user_table_alias ON base_user_table_alias.`id` = `cactivity`.`userId` LEFT JOIN `db1_tblprefix1_base_user_suspend` base_user_suspend_table_alias ON base_user_suspend_table_alias.`userId` = `base_user_table_alias`.`id` INNER JOIN db1_tblprefix1_newsfeed_action_feed action_feed ON activity.id=action_feed.activityId LEFT JOIN db1_tblprefix1_newsfeed_follow follow ON action_feed.feedId = follow.feedId AND action_feed.feedType = follow.feedType WHERE (`base_user_suspend_table_alias`.`id` IS NULL) AND cactivity.userId = 7 AND activity.status='active' AND activity.timeStamp<1422551122 AND ( ( follow.userId=7 AND activity.visibility & 2 ) ) UNION ALL SELECT action.`id`, action.`entityId`, action.`entityType`, action.`pluginKey`, action.`data`, activity.timeStamp FROM db1_tblprefix1_newsfeed_action action INNER JOIN db1_tblprefix1_newsfeed_activity activity ON action.id = activity.actionId INNER JOIN `db1_tblprefix1_newsfeed_action_set` cactivity ON action.id = cactivity.actionId INNER JOIN `db1_tblprefix1_base_user` base_user_table_alias ON base_user_table_alias.`id` = `cactivity`.`userId` LEFT JOIN `db1_tblprefix1_base_user_suspend` base_user_suspend_table_alias ON base_user_suspend_table_alias.`userId` = `base_user_table_alias`.`id` WHERE (`base_user_suspend_table_alias`.`id` IS NULL) AND cactivity.userId = 7 AND activity.status='active' AND activity.timeStamp<1422551122 AND ( ( activity.userId=7 AND activity.visibility & 4 ) ) UNION ALL SELECT action.`id`, action.`entityId`, action.`entityType`, action.`pluginKey`, action.`data`, activity.timeStamp FROM db1_tblprefix1_newsfeed_action action INNER JOIN db1_tblprefix1_newsfeed_activity activity ON action.id = activity.actionId INNER JOIN `db1_tblprefix1_newsfeed_action_set` cactivity ON action.id = cactivity.actionId INNER JOIN `db1_tblprefix1_base_user` base_user_table_alias ON base_user_table_alias.`id` = `cactivity`.`userId` LEFT JOIN `db1_tblprefix1_base_user_suspend` base_user_suspend_table_alias ON base_user_suspend_table_alias.`userId` = `base_user_table_alias`.`id` INNER JOIN db1_tblprefix1_newsfeed_action_feed action_feed ON activity.id=action_feed.activityId WHERE (`base_user_suspend_table_alias`.`id` IS NULL) AND cactivity.userId = 7 AND activity.status='active' AND activity.timeStamp<1422551122 AND ( ( action_feed.feedId=7 AND action_feed.feedType="user" AND activity.visibility & 8 ) ) UNION ALL SELECT action.`id`, action.`entityId`, action.`entityType`, action.`pluginKey`, action.`data`, activity.timeStamp FROM db1_tblprefix1_newsfeed_action action INNER JOIN db1_tblprefix1_newsfeed_activity activity ON action.id = activity.actionId INNER JOIN `db1_tblprefix1_newsfeed_action_set` cactivity ON action.id = cactivity.actionId INNER JOIN `db1_tblprefix1_base_user` base_user_table_alias ON base_user_table_alias.`id` = `cactivity`.`userId` LEFT JOIN `db1_tblprefix1_base_user_suspend` base_user_suspend_table_alias ON base_user_suspend_table_alias.`userId` = `base_user_table_alias`.`id` INNER JOIN db1_tblprefix1_newsfeed_activity subscribe ON activity.actionId=subscribe.actionId and subscribe.activityType='subscribe' AND subscribe.userId=7 WHERE (`base_user_suspend_table_alias`.`id` IS NULL) AND cactivity.userId = 7 AND activity.status='active' AND activity.timeStamp<1422551122 ) b GROUP BY b.`id` ORDER BY MAX(b.timeStamp) DESC LIMIT 0, 10