Выборки без использования ключей
Добавлено: 2010-07-02 14:43:02
сабж вот нашёл... потому что долго делается.
Код: Выделить всё
mysql> use host-food_bill
Database changed
mysql> SELECT `ID` FROM `Tasks` WHERE (`IsActive` = 'yes' AND `IsExecuted` = 'no' AND `ExecuteDate` < UNIX_TIMESTAMP() AND `Errors` < 5) ORDER BY `CreateDate` DESC LIMIT 0, 1;
+--------+
| ID |
+--------+
| 147149 |
+--------+
1 row in set (3.38 sec)
mysql> explain SELECT `ID` FROM `Tasks` WHERE (`IsActive` = 'yes' AND `IsExecuted` = 'no' AND `ExecuteDate` < UNIX_TIMESTAMP() AND `Errors` < 5) ORDER BY `CreateDate` DESC LIMIT 0, 1;
+----+-------------+-------+------+---------------+------+---------+------+--------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+--------+-----------------------------+
| 1 | SIMPLE | Tasks | ALL | NULL | NULL | NULL | NULL | 166914 | Using where; Using filesort |
+----+-------------+-------+------+---------------+------+---------+------+--------+-----------------------------+
1 row in set (0.02 sec)
mysql>