one of the tab is broken in the Application (when hit that tab it keeps on rotating and calling the particular service and getting 404 error after sometime). we created indexes for few columns in Application DB to see if that improves performance. Creating indexes didn't make much difference.
so We planned to rewrite the sql query to improve the performance and fix it.
select distinct
editedUser.*
from
users editedUser,
relationship_ref editedUserRelationship,
users approvingUser,
user_role approvingUserRoles,
role_permission approvingUserRolePermissions,
account approvingUserAccount
where
approvingUser.user_id = 175263
and approvingUser.user_id = approvingUserRoles.user_id
and approvingUserRoles.role_id = approvingUserRolePermissions.role_id
and approvingUserRoles.user_role_status_id = 2
and editedUserRelationship.relationship_id =
editedUser.submitted_relationship_id
and (approvingUser.account_id = approvingUserAccount.account_id
or approvingUser.account_id is null)
and editedUser.review_status = 'R'
and approvingUserRolePermissions.permission_id =
editedUserRelationship.view_pending_permission_id;
It is taking nearly 6 mins.So can one please suggest how to use the proper joins in this query. It has 36 columns and 30,000 records.