Answer the question
In order to leave comments, you need to log in
Partitioning a MySql table by two fields?
There is a table:
CREATE TABLE `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created` datetime DEFAULT CURRENT_TIMESTAMP,
`updated` datetime DEFAULT ON UPDATE CURRENT_TIMESTAMP,
`status` tinyint(1) NOT NULL DEFAULT 0,
.. ..
PRIMARY KEY (`id`),
....
) ENGINE=InnoDB DEFAULT CHARSET=utf8 It is
necessary to partition this table by two fields: updated and status
Moreover, by the updated field, for example, by quarterly or by year, and by the status field, for example, from value equal to 2
Need an example of this breakdown into partitions according to the above criteria...
Answer the question
In order to leave comments, you need to log in
https://dev.mysql.com/doc/refman/5.6/en/partitioni...
PARTITION BY RANGE(YEAR(updated))
SUBPARTITION BY HASH(status)
SUBPARTITIONS 4 (
PARTITION p0 VALUES LESS THAN (2000),
PARTITION p1 VALUES LESS THAN (2010),
PARTITION p2 VALUES LESS THAN MAXVALUE
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question