Both email columns have the same format (varchar) and are indexed individually:

describe SELECT person FROM person WHERE email1='foo' OR email2='foo';
+--------+------+---------------+------+---------+------+-------+-------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+--------+------+---------------+------+---------+------+-------+-------------+
| person | ALL | email1,email2 | NULL | NULL | NULL | 57051 | Using where |
+--------+------+---------------+------+---------+------+-------+-------------+



mysql> describe SELECT person FROM person WHERE email1='foo' and email2='foo';
+--------+------+---------------+--------+---------+-------+------+-------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+--------+------+---------------+--------+---------+-------+------+-------------+
| person | ref | email1,email2 | email1 | 101 | const | 1 | Using where |
+--------+------+---------------+--------+---------+-------+------+-------------+


I'm curious why this is. (In general, I have been surprised by how often indices are not used even if they exist.)

Henning Schulzrinne



---------------------------------------------------------------------
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