Запрос:
-----------------------{
SELECT
p.*,
s.short AS state_id,s.full AS state_full,
c.short AS country_id,c.full AS country_full
FROM billing_preferences AS p
LEFT JOIN states AS s ON (s.short=p.state)
LEFT JOIN countries AS c ON (c.short=p.country)
WHERE p.uid=25
}-----------------------
Его explain:
+----+-------------+-------+--------+---------------+-------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+---------------+-------+---------+-------+------+-------+
| 1 | SIMPLE | p | const | uid,uid_2 | uid | 4 | const | 1 | |
| 1 | SIMPLE | s | ALL | NULL | NULL | NULL | NULL | 817 | |
| 1 | SIMPLE | c | eq_ref | short | short | 6 | const | 1 | |
+----+-------------+-------+--------+---------------+-------+---------+-------+------+-------+
Индексы таблицы states:
+--------+------------+-----------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+--------+------------+-----------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+
| states | 0 | PRIMARY | 1 | id_state | A | 269 | NULL | NULL | | BTREE | |
| states | 0 | id_country | 1 | id_country | A | 269 | NULL | NULL | | BTREE | |
| states | 0 | id_country | 2 | short | A | 269 | NULL | NULL | | BTREE | |
| states | 0 | short_country | 1 | short_country | A | 269 | NULL | NULL | | BTREE | |
| states | 0 | short_country | 2 | short | A | 269 | NULL | NULL | | BTREE | |
| states | 1 | id_country_2 | 1 | id_country | A | 269 | NULL | NULL | | BTREE | |
| states | 1 | short_country_2 | 1 | short_country | A | 269 | NULL | NULL | | BTREE | |
+--------+------------+-----------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+
*****Вопрос*****
Интресно, почему для таблицы states AS s при выборке не используются индексы.
Знает кто?