开发者

mysql index optimization problem

I have a query like below.

SE开发者_如何学PythonLECT a,b,c,d 
FROM table_name  
WHERE e=1 AND f=0 
GROUP BY d 
ORDER BY id DESC LIMIT 5

when I indexed (e,f,d) query time : 4 sec.

when I indexed (d,e,f) query time : 20 sec.

So that I understand that index colums ordering is important. Which index would be better for mysql?


Indexes should first satisfy the where clause, then the group or order clause. Always use EXPLAIN on your query to see how it is performed

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜