Dr. Frank Ullrich wrote:

> Steve,
> what did explain tell you in either case?


Good question Dr. Ullrich.


mysql> explain select rec_no,phone_no from White where phone_no=0636941;
+-------+------+---------------+------+---------+------+----------+------------+
| table | type | possible_keys | key  | key_len | ref  | rows     | Extra      |
+-------+------+---------------+------+---------+------+----------+------------+
| White | ALL  | phone_no      | NULL |    NULL | NULL | 22160316 | where used |
+-------+------+---------------+------+---------+------+----------+------------+
1 row in set (0.01 sec)
 
mysql> explain select rec_no,phone_no from White where phone_no='0636941';
+-------+------+---------------+----------+---------+-------+------+------------+
| table | type | possible_keys | key      | key_len | ref   | rows | Extra      |
+-------+------+---------------+----------+---------+-------+------+------------+
| White | ref  | phone_no      | phone_no |       8 | const |    1 | where used |
+-------+------+---------------+----------+---------+-------+------+------------+
1 row in set (0.00 sec)   


So it's unable to use phone_no as a key, and therefore does a full scan.  And 
then apparently proceeds to scan each row, converting phone_no to an integer to
compare to the constant.

Seems naive to me, since the datatype of the field is known, why not convert 
the constant instead?  Then everything would work at least as well, and always 
faster.

-steve



-- 
Steve Rapaport
World Citizen


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to