I have this table
+---------------+------------------+------+-----+------------+--------------
--+
| Field         | Type             | Null | Key | Default    | Extra
|
+---------------+------------------+------+-----+------------+--------------
--+
| ID            | int(10) unsigned |      | PRI | NULL       |
auto_increment |
| Nick          | varchar(50)      |      | MUL |            |
|
| Sexo          | tinyint(1)       |      | MUL | 0          |
|
| OK            | tinyint(1)       |      | MUL | 0          |
|
| Inicial       | char(1)          |      | MUL |            |
|
+---------------+------------------+------+-----+------------+--------------
--+

With this index
| genteirc |          0 | ID_2                         |            1 | ID
| A         |       22632 |     NULL | NULL   |          |
| genteirc |          1 | ok                  |            1 | OK
| A         |           2 |     NULL | NULL   |          |
| genteirc |          1 | inicial             |            1 | Inicial
| A         |       22632 |     NULL | NULL   |          |
| genteirc |          1 | sexo                         |            1 | Sexo
| A         |       22632 |     NULL | NULL   |          |


when I run this query
mysql> explain select Nick  from mytable where Inicial='P' AND Sexo=1 and
ok=1;
.
+----------+------+-----------------------------------+-------------+-------
--+-------+------+------------+
| table    | type | possible_keys                     | key         |
key_len | ref   | rows | Extra      |
+----------+------+-----------------------------------+-------------+-------
--+-------+------+------------+
| mytable | ref  | ok,inicial,sexo | ok |       1 | const |   10 | where
used |
+----------+------+-----------------------------------+-------------+-------
--+-------+------+------------+

only one index is used, why?

ok is  1 or 0
sexo is 1 or 0

but inicial is A, B, C, D, E, F, G.....Z
So it would be better to use Inicial as index bacause should get less
records...


whta's happening?

Thnaks




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