I want to optimize a slow query for speed, after reading this:
http://dev.mysql.com/doc/refman/5.1/en/group-by-optimization.html
EXPLAIN SELECT SUM(uid) FROM logs WHERE uid='206' and start>='2008-12-16' GROUP BY uid ORDER BY NULL;
+----+-------------+----------+-------+---------------+------+---------+------+------+-------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+-------+---------------+------+---------+------+------+-------------------------------------------+
| 1 | SIMPLE | logs | range | uid | uid | 12 | NULL | 1 | Using where; Using index; Using temporary |
+----+-------------+----------+-------+---------------+------+---------+------+------+-------------------------------------------+
uid is NOT a PK. There is a single multi-key:
KEY `uid` (`uid`,`start`)
It's a BTREE index (InnoDB).
ORDER BY NULL was added in an attempt to avoid using temporary tables, but it's still there. Can someone please help? This is an example query please pay no attention if it doesn't make sense.
P.S.: what does "Using where" mean?
Edited 1 time(s). Last edit at 12/23/2008 02:13AM by rihad rihad.