我已經創建了一個sql表,我在磁盤上創建了索引文件。 桌上有超過100萬條記錄。 我已經添加了ext和size的索引,但是它仍然需要一分鐘才能執行這個查詢,它告訴我ext使用的空間量。 如何提高此選擇的性能?mysql:我該如何提高這個mysql select語句的性能
select ext,
ROUND((sum(size)/(1073741824))) as TotalSizeGB,
count(*) as Count
from fileindex
group by ext
order by TotalSizeGB desc;
Explain輸出:
|| *id* || *select_type* || *table* || *type* || *possible_keys* || *key* || *key_len* || *ref* || *rows* || *Extra* ||
|| 1 || SIMPLE || fileindex || index || _NULL_ || ext || 27 || _NULL_ || 1892234 || Using index; Using temporary; Using filesort ||
你能告訴我們的查詢計劃嗎?使用EXPLAIN http://dev.mysql.com/doc/refman/5.5/en/explain.html – 2011-02-22 18:41:19
我不認爲你可以改善它,因爲它加載**全部**表中的數據。 – Augusto 2011-02-22 18:49:53
@augusto除非在`ext`上缺少可用於執行分組的索引 – 2011-02-22 18:52:01