代碼: 選擇全部
MariaDB [test1]> EXPLAIN SELECT * FROM `sell_pp` WHERE date like '2008-10-10%';
+------+-------------+---------+------+---------------+------+---------+------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+---------+------+---------------+------+---------+------+---------+-------------+
| 1 | SIMPLE | sell_pp | ALL | date | NULL | NULL | NULL | 2615279 | Using where |
+------+-------------+---------+------+---------------+------+---------+------+---------+-------------+
1 row in set (0.00 sec)
MariaDB [test1]> EXPLAIN SELECT * FROM `sell_pp` WHERE date >= '2008-10-10 00:00:00' and date <= '2008-10-10 23:59:59';
+------+-------------+---------+-------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+---------+-------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | sell_pp | range | date | date | 8 | NULL | 669 | Using where |
+------+-------------+---------+-------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)
MariaDB [test1]> EXPLAIN SELECT * FROM `sell_pp` WHERE date BETWEEN '2008-10-10 00:00:00' and '2008-10-10 23:59:59';
+------+-------------+---------+-------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+---------+-------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | sell_pp | range | date | date | 8 | NULL | 669 | Using where |
+------+-------------+---------+-------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)