Reputation: 165
I have a very simple table and a query I would like to know if can be optimized in some way? Is there something better to use than the EXPLAIN statement when looking for a query optimization?
It only has 1500 rows now, but it's intented to have a lot more (probably above 500,000 or 1,000,000 rows).
Query:
SELECT id, SUM( ABS(weight)) AS sumWeight FROM myTable GROUP BY id ORDER BY sumWeight ASC LIMIT 1
Table structre
Field Type Null Key Default Extra
id mediumint(8) unsigned NO PRI NULL
otherId bigint(20) unsigned NO PRI NULL
weight smallint(6) NO NULL
When I use EXPLAIN to see what's going on it displays:
select_type table type possible_keys key key_len ref rows Extra
SIMPLE myTable index NULL PRIMARY 11 NULL 1573 Using temporary; Using filesort
Upvotes: 0
Views: 79
Reputation: 87
Upvotes: 1