MySQL Forums
Forum List  »  Newbie

Re: Optimizing GROUP BY
Posted by: rihad rihad
Date: December 24, 2008 03:05AM

A biggest surprise...

Quote

mysql> EXPLAIN SELECT SUM(uid) FROM logs WHERE uid=206 GROUP BY uid ORDER BY NULL;
+----+-------------+----------+------+---------------+------+---------+-------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+------+---------------+------+---------+-------+------+-------------+
| 1 | SIMPLE | ipn_log | ref | uid | uid | 4 | const | 612 | Using index |
+----+-------------+----------+------+---------------+------+---------+-------+------+-------------+
1 row in set (0.00 sec)

Taking away the quotes from the constant '206' solved the problem... Now there's no type conversion taking place so index magic works. But... doesn't MySQL parser recognize that '206' is a numerical constant and treat it respectively? I always thought I should quote my literals just in case. Very embarrassing on my part....

Options: ReplyQuote


Subject
Written By
Posted
December 23, 2008 02:11AM
December 23, 2008 11:43AM
December 23, 2008 10:45PM
December 24, 2008 02:54AM
Re: Optimizing GROUP BY
December 24, 2008 03:05AM
December 24, 2008 05:20PM
December 24, 2008 04:13AM
December 24, 2008 05:27PM
December 24, 2008 12:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.