Description:
why
How to repeat:
mysql> select a,b from t3 order by b desc limit 5;
+--------+---------------------+
| a | b |
+--------+---------------------+
| 100000 | 2019-11-11 16:32:53 |
| 99999 | 2019-11-11 16:32:53 |
| 99998 | 2019-11-11 16:32:53 |
| 99997 | 2019-11-11 16:32:53 |
| 99996 | 2019-11-11 16:32:53 |
+--------+---------------------+
5 rows in set (0.00 sec)
mysql>
mysql>
mysql> select max(a) from t3;
+--------+
| max(a) |
+--------+
| 99999 |
+--------+
1 row in set (0.00 sec)
mysql> select min(a) from t3;
+--------+
| min(a) |
+--------+
| |
+--------+
1 row in set (0.00 sec)
mysql> select a,b from t3 limit 5;
+------+---------------------+
| a | b |
+------+---------------------+
| | 2019-11-11 16:05:26 |
| 1 | 2019-11-11 16:05:30 |
| 2 | 2019-11-11 16:05:34 |
| 3 | 2019-11-11 16:05:37 |
| 4 | 2019-11-11 16:05:40 |
+------+---------------------+
5 rows in set (0.00 sec)
mysql> select a,b from t3 order by b desc limit 5;
+--------+---------------------+
| a | b |
+--------+---------------------+
| 100000 | 2019-11-11 16:32:53 |
| 99999 | 2019-11-11 16:32:53 |
| 99998 | 2019-11-11 16:32:53 |
| 99997 | 2019-11-11 16:32:53 |
| 99996 | 2019-11-11 16:32:53 |
+--------+---------------------+
5 rows in set (0.00 sec)
mysql> show create table t3\G;
*************************** 1. row ***************************
Table: t3
Create Table: CREATE TABLE `t3` (
`a` char(20) DEFAULT NULL,
`b` timestamp NULL DEFAULT NULL,
UNIQUE KEY `idx_t3` (`a`),
KEY `idx_t3_time` (`b`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)
mysql> show index from t3;
+-------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| t3 | 0 | idx_t3 | 1 | a | A | 100001 | NULL | NULL | YES | BTREE | | |
| t3 | 1 | idx_t3_time | 1 | b | A | 441 | NULL | NULL | YES | BTREE | | |
+-------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
2 rows in set (0.00 sec)
The mysql server is 5.7.23.