CREATE TABLE `routes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userId` int(11) NOT NULL,
`created` datetime NOT NULL,
`createdTimezoneOffset` smallint(6) NOT NULL DEFAULT '0',
`archive` tinyint(1) NOT NULL DEFAULT '0',
`deleted` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`,`created`,`archive`)
) ENGINE=InnoDB AUTO_INCREMENT=1254237 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
/*!50100 PARTITION BY LIST (archive)
SUBPARTITION BY HASH (YEAR(created))
(PARTITION p0 VALUES IN (0)
(SUBPARTITION s0 ENGINE = InnoDB,
SUBPARTITION s1 ENGINE = InnoDB,
SUBPARTITION s2 ENGINE = InnoDB,
SUBPARTITION s3 ENGINE = InnoDB),
PARTITION p1 VALUES IN (1)
(SUBPARTITION s4 ENGINE = InnoDB,
SUBPARTITION s5 ENGINE = InnoDB,
SUBPARTITION s6 ENGINE = InnoDB,
SUBPARTITION s7 ENGINE = InnoDB)) */
EXPLAIN SELECT * FROM routes WHERE archive = 1 AND created >= '2020-01-01 00:00:00';
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE routes p1_s4,p1_s5,p1_s6,p1_s7 ALL [NULL] [NULL] [NULL] [NULL] 497 616 3,33 Using where
EXPLAIN SELECT * FROM routes WHERE archive = 1 AND created = '2020-01-01 00:00:00';
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE routes p1_s4 ALL [NULL] [NULL] [NULL] [NULL] 477 588 1 Using where