четверг, 3 декабря 2009 г.

Вот такой странный Mysql

mysql> explain SELECT * FROM last_registrations ORDER BY date DESC LIMIT 100;
+----+-------------+--------------------+-------+---------------+--------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------------+-------+---------------+--------+---------+------+------+-------+
| 1 | SIMPLE | last_registrations | index | NULL | k_date | 4 | NULL | 100 | |
+----+-------------+--------------------+-------+---------------+--------+---------+------+------+-------+
1 row in set (0.01 sec)

mysql> explain SELECT * FROM last_registrations ORDER BY date DESC LIMIT 1000;
+----+-------------+--------------------+-------+---------------+--------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------------+-------+---------------+--------+---------+------+------+-------+
| 1 | SIMPLE | last_registrations | index | NULL | k_date | 4 | NULL | 1000 | |
+----+-------------+--------------------+-------+---------------+--------+---------+------+------+-------+
1 row in set (0.00 sec)

mysql> explain SELECT * FROM last_registrations ORDER BY date DESC LIMIT 10000;
+----+-------------+--------------------+------+---------------+------+---------+------+--------+----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------------+------+---------------+------+---------+------+--------+----------------+
| 1 | SIMPLE | last_registrations | ALL | NULL | NULL | NULL | NULL | 868402 | Using filesort |
+----+-------------+--------------------+------+---------------+------+---------+------+--------+----------------+
1 row in set (0.01 sec)

Комментариев нет: