私はこのクエリを実行していますが、結果はうまくいっていますが、時間がかかりすぎるということです.誰かがこれを効率的にする方法を教えてもらえますか.最初は3つのテーブルで結合を使用していますが、そのクエリはこれよりも時間がかかります。前もって感謝します。
SELECT
ee_expert.expert_id ,
AVG( ee_expert_rating.rating_stars ) AS total_rating,
ee_expert.expert_id,
COUNT( DISTINCT ee_expert_rating.rating_id ) AS rating_count
FROM
ee_expert_rating
RIGHT JOIN ee_expert
ON ee_expert.expert_id = ee_expert_rating.expert_id
WHERE
expert_verified_email =2
AND expert_brief_description != ''
AND expert_account_status =1
AND ee_expert.expert_id IN
(
SELECT
expert_id
FROM
ee_expert_categories
WHERE
ee_expert_categories.category_id =5
GROUP BY
expert_id
)
GROUP BY
ee_expert.expert_id
ORDER BY
rating_count DESC