我有以下查询,我正在循环选择类别。 任何人都可以看到加快此查询速度的方法,因为它目前花费太长时间才能返回结果。
SELECT COUNT(entry_id) AS count_result
FROM (
SELECT sub.entry_id
FROM exp_judging AS jud1
JOIN exp_judging AS jud2 ON jud1.rel_id = jud2.rel_id AND jud2.judge_id = 779 AND jud2.stage_2 IS NULL
JOIN exp_submissions AS sub ON jud2.rel_id = sub.id
WHERE jud1.stage_1 = 1
AND sub.member_group = 5
AND sub.category_id = 10
GROUP BY jud1.rel_id
HAVING COUNT(sub.entry_id) >= 3
) AS a
答案 0 :(得分:0)
我不明白为什么你需要那里的nestes SELECT
语句。它看起来像而不是
SELECT COUNT(entry_id) AS count_result
FROM (
SELECT sub.entry_id
...
) AS a
你可以简单地做
SELECT COUNT(sub.entry_id) AS count_result
...
这可能有助于DBMS优化您的请求。