我有查詢MySQL的左連接查詢優化
SELECT P.*, COUNT(L.to) AS likes, U.name AS ownerName, U.username AS ownerUsername,
U.picture AS ownerPicture
FROM sn_posts P LEFT JOIN sn_users AS U
ON U.id = P.ownerID
LEFT JOIN sn_likes AS L
ON L.to = P.id
WHERE (P.ownerID = 69)
GROUP BY P.id
ORDER BY P.id DESC
它採取 - 0.3337秒的時間,
我想優化我上面查詢.. –
你好,歡迎來到SO--請儘量提供更多信息 - 表格結構,數據量,指標等 - 所以人們實際上有辦法幫助你。 –
您可以將索引添加到聯接列中,除此之外,您的查詢對我來說確實很好。 –