But loading the newsfeed is taking so long (sometimes more then 15 seconds ).
How can i solve this?
this is the query that takes so long
# Time: 160210 21:41:44# User@Host: XXXXXXX @ localhost []# Query_time: 26.482464 Lock_time: 0.001632 Rows_sent: 5 Rows_examined: 89231SET timestamp=1455136904;SELECT b.`id` FROM ( SELECT action.`id`, action.`entityId`, action.`entityType`, action.`pluginKey`, action.`data`, activity.timeStamp FROM ow_newsfeed_action action INNER JOIN ow_newsfeed_activity activity ON action.id = activity.actionId INNER JOIN `ow_newsfeed_action_set` cactivity ON action.id = cactivity.actionId INNER JOIN `ow_base_user` base_user_table_alias ON base_user_table_alias.`id` = `cactivity`.`userId` LEFT JOIN `ow_base_user_suspend` base_user_suspend_table_alias ON base_user_suspend_table_alias.`userId` = `base_user_table_alias`.`id` LEFT JOIN `ow_base_user_disapprove` base_user_approve_table_alias ON base_user_approve_table_alias.`userId` = `base_user_table_alias`.`id` INNER JOIN ow_newsfeed_action_feed action_feed ON activity.id=action_feed.activityId LEFT JOIN ow_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 (`base_user_approve_table_alias`.`id` IS NULL) AND (`base_user_table_alias`.`emailVerify` = 1) AND cactivity.userId = 2 AND activity.status='active' AND activity.timeStamp<1455136876 AND ( ( follow.userId=2 AND activity.visibility & 2 ) )
UNION
SELECT action.`id`, action.`entityId`, action.`entityType`, action.`pluginKey`, action.`data`, activity.timeStamp FROM ow_newsfeed_action action INNER JOIN ow_newsfeed_activity activity ON action.id = activity.actionId INNER JOIN `ow_newsfeed_action_set` cactivity ON action.id = cactivity.actionId INNER JOIN `ow_base_user` base_user_table_alias ON base_user_table_alias.`id` = `cactivity`.`userId` LEFT JOIN `ow_base_user_suspend` base_user_suspend_table_alias ON base_user_suspend_table_alias.`userId` = `base_user_table_alias`.`id` LEFT JOIN `ow_base_user_disapprove` base_user_approve_table_alias ON base_user_approve_table_alias.`userId` = `base_user_table_alias`.`id` WHERE (`base_user_suspend_table_alias`.`id` IS NULL) AND (`base_user_approve_table_alias`.`id` IS NULL) AND (`base_user_table_alias`.`emailVerify` = 1) AND cactivity.userId = 2 AND activity.status='active' AND activity.timeStamp<1455136876 AND ( ( activity.userId=2 AND activity.visibility & 4 ) )
UNION
SELECT action.`id`, action.`entityId`, action.`entityType`, action.`pluginKey`, action.`data`, activity.timeStamp FROM ow_newsfeed_action action INNER JOIN ow_newsfeed_activity activity ON action.id = activity.actionId INNER JOIN `ow_newsfeed_action_set` cactivity ON action.id = cactivity.actionId INNER JOIN `ow_base_user` base_user_table_alias ON base_user_table_alias.`id` = `cactivity`.`userId` LEFT JOIN `ow_base_user_suspend` base_user_suspend_table_alias ON base_user_suspend_table_alias.`userId` = `base_user_table_alias`.`id` LEFT JOIN `ow_base_user_disapprove` base_user_approve_table_alias ON base_user_approve_table_alias.`userId` = `base_user_table_alias`.`id` INNER JOIN ow_newsfeed_action_feed action_feed ON activity.id=action_feed.activityId WHERE (`base_user_suspend_table_alias`.`id` IS NULL) AND (`base_user_approve_table_alias`.`id` IS NULL) AND (`base_user_table_alias`.`emailVerify` = 1) AND cactivity.userId = 2 AND activity.status='active' AND activity.timeStamp<1455136876 AND ( ( action_feed.feedId=2 AND action_feed.feedType="user" AND activity.visibility & 8 ) )
UNION
SELECT action.`id`, action.`entityId`, action.`entityType`, action.`pluginKey`, action.`data`, activity.timeStamp FROM ow_newsfeed_action action INNER JOIN ow_newsfeed_activity activity ON action.id = activity.actionId INNER JOIN `ow_newsfeed_action_set` cactivity ON action.id = cactivity.actionId INNER JOIN `ow_base_user` base_user_table_alias ON base_user_table_alias.`id` = `cactivity`.`userId` LEFT JOIN `ow_base_user_suspend` base_user_suspend_table_alias ON base_user_suspend_table_alias.`userId` = `base_user_table_alias`.`id` LEFT JOIN `ow_base_user_disapprove` base_user_approve_table_alias ON base_user_approve_table_alias.`userId` = `base_user_table_alias`.`id` INNER JOIN ow_newsfeed_activity subscribe ON activity.actionId=subscribe.actionId and subscribe.activityType='subscribe' AND subscribe.userId=2 WHERE (`base_user_suspend_table_alias`.`id` IS NULL) AND (`base_user_approve_table_alias`.`id` IS NULL) AND (`base_user_table_alias`.`emailVerify` = 1) AND cactivity.userId = 2 AND activity.status='active' AND activity.timeStamp<1455136876
) b
GROUP BY b.`id` ORDER BY MAX(b.timeStamp) DESC LIMIT 0, 5;