Hiya
Im wondering if someone could help me understand this. If you look at my
two queries below. By the ORDER BY one is using ` and the other ', as a
result, if you do an explain you will see that the top query does a
filesort, while the other does not.
Would anyone know why.
mysql> explain SELECT `Contact`.`id`, `Contact`.`name`,
`Contact`.`surname`, `Contact`.`mobile`, `Contact`.`user_id`,
`Contact`.`active`, `Contact`.`created` FROM `contacts` AS `Contact`
WHERE `Contact`.`user_id` = 10203 AND `Contact`.`active` = '1' ORDER
BY `name` asc LIMIT 10;
+----+-------------+---------+------+---------------+------+---------+------+--------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len |
ref | rows | Extra |
+----+-------------+---------+------+---------------+------+---------+------+--------+-----------------------------+
| 1 | SIMPLE | Contact | ALL | NULL | NULL | NULL |
NULL | 344709 | Using where; Using filesort |
+----+-------------+---------+------+---------------+------+---------+------+--------+-----------------------------+
1 row in set (0.00 sec)
mysql> explain SELECT `Contact`.`id`, `Contact`.`name`,
`Contact`.`surname`, `Contact`.`mobile`, `Contact`.`user_id`,
`Contact`.`active`, `Contact`.`created` FROM `contacts` AS `Contact`
WHERE `Contact`.`user_id` = 10203 AND `Contact`.`active` = '1' ORDER
BY 'name' asc LIMIT 10;
+----+-------------+---------+------+---------------+------+---------+------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len |
ref | rows | Extra |
+----+-------------+---------+------+---------------+------+---------+------+--------+-------------+
| 1 | SIMPLE | Contact | ALL | NULL | NULL | NULL |
NULL | 344710 | Using where |
+----+-------------+---------+------+---------------+------+---------+------+--------+-------------+
1 row in set (0.00 sec)
Thanks
Brent
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org