开发者

MYSQL using temporary when Group By

开发者 https://www.devze.com 2023-04-08 20:48 出处:网络
I have this query: 开发者_运维问答SELECT m.Number FROM table m WHERE m.IdA = _IdA AND m.IdB = _IdB

I have this query:

开发者_运维问答
SELECT m.Number
FROM table m
WHERE m.IdA = _IdA
    AND m.IdB = _IdB
    AND m.IdC = _IdC
GROUP BY m.Number
ORDER BY m.Number;

Where _IdA, _IdB & _IdC are the parameters. If I check it with EXPLAIN it says no using temporary, but if the values of those parameters doesn't return any row EXPLAIN says "using temporary"

I'd like to avoid using temporary....Any ideas?


Create a composite index (IdA, IdB, IdC, Number).

0

精彩评论

暂无评论...
验证码 换一张
取 消