I have the query in which data are coming from multiple tables.
SELECT iUserID,
iUserID AS userID,
(CASE vUSBG
WHEN 1 THEN 'Yes'
WHEN 0 THEN 'No'
END) AS vUSBG,
concat(vFirstname,' ',vLastname) AS Name,
vEmail,
eType,
eStatus,
tAddedDate,
eExpert,
eAdmin,
(SELECT count(iUserID) AS total
FROM tbl_friend
WHERE iUserID = tbl_user.iUserID) AS count_f,
(SELECT COUNT(*)
FROM bar_followers
WHERE bar_followers.iUserID = tbl_user.iUserID) AS bar_follows,
(SELECT COUNT(b.iBrandID)
FROM tbl_company_follow,
tbl_brand b
WHERE tbl_company_follow.iUserID = tbl_user.iUserID
AND b.iCompanyID = tbl_company_follow.iCompanyID) AS brand_follows,
(SELECT sum(points) AS totalpoints
FROM tbl_points,
tbl_post p
WHERE iUserID = tbl_user.iUserID
AND p.iPostID = tbl_points.post_id) AS countPoints
FROM tbl_user
This Query took 8.3595 seconds
How can i minimize the time?
8.3595 sec