Relative Content

Tag Archive for mysqlindexingsql-order-byprimary-key

mysql5.7 order by id desc limit n ;Optimizer selects primary key index

CREATE TABLE `test` ( `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, `month` timestamp NOT NULL DEFAULT ‘2018-01-01 00:00:00’, `b` varchar(255) NOT NULL DEFAULT ”, `c` varchar(255) NOT NULL DEFAULT ”, `d` varchar(255) NOT NULL DEFAULT ”, `e` varchar(255) NOT NULL DEFAULT ”, … PRIMARY KEY (`id`), INDEX `idx_month_b`(`month`, `b`) USING BTREE, INDEX `idx_d`(`c`) USING BTREE, … […]