+----------------------+---------------------+------+------+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------------+---------------------+------+------+---------------------+----------------+ | id | bigint(20) UNSIGNED | NO | PRI | NULL | auto_increment | | xxxxxx | varchar(50) | NO | MUL | NULL | | | xxxxxxxx | char(14) | NO | MUL | NULL | | | xxxxxxxxxxxx | varchar(32) | NO | | NULL | | | xxxxxxxxxxxxxx | varchar(4) | NO | | NULL | | | xxxxxxxxxxxxxxxx | varchar(255) | NO | | NULL | | | xxxxxxxxxxxxx | varchar(20) | NO | | | | | xxxxxxxxxxxxxxxxxx | varchar(32) | NO | | NULL | | | xxxxxxxxxxxxx | varchar(128) | NO | | NULL | | | xxxxxxxxxxxxx | varchar(20) | NO | | NULL | | | xxxxxxxxxxx | timestamp | NO | | 1971-01-01 08:00:00 | | | xxxxxxxx | tinyint(4) | YES | | NULL | | | xxxx | tinyint(4) | NO | MUL | 0 | | | xxxxxxxxx | int(11) | NO | MUL | NULL | | | xxxxxxxxxxx | int(11) | NO | | 0 | | | xxxxxxxx | int(10) | NO | MUL | NULL | | | xxxxxxxxx | varchar(10) | NO | | | | | xxxxxxxxxxxxxxxxx | varchar(100) | YES | | | | | xxxxxxxxxxxx | tinyint(4) | YES | | 0 | | | xxxxxxx | varchar(25) | YES | | NULL | | | xxxxxxxxxxxx | varchar(14) | NO | | | | | xxxxxxxxxxxxxx | tinyint(1) | NO | | 0 | | | xxxxxxxxxxxxxx | varchar(256) | NO | | | | | xxxxxxxxxxxxxx | varchar(10) | NO | | | | | xxxxxxxxxxxxxx | varchar(64) | NO | | | | +----------------------+---------------------+------+------+---------------------+----------------+
id是自增主键的,记得tidb 4.x 以下,select min,max from tb 是全表扫描,min和max不能 同时使用,要拆分2条sql,只有 select min from tb ; select max from tb;才是最快的。