I have a table with ~20M rows and every query against it will include state or city or a combination so I was thinking of partitioning the table using a combo of the two fields like so:
ALTER TABLE `test`.`test`
PARTITION BY RANGE COLUMNS (city, state) (
PARTITION p0 VALUES LESS THAN ('a','AE'),
PARTITION p1 VALUES LESS THAN ('c','AE'),
PARTITION p2 VALUES LESS THAN ('e','AE'),
PARTITION p3 VALUES LESS THAN ('g','AE'),
PARTITION p4 VALUES LESS THAN ('i','AE'),
PARTITION p5 VALUES LESS THAN ('k','AE'),
PARTITION p6 VALUES LESS THAN ('m','AE'),
PARTITION p7 VALUES LESS THAN ('o','AE'),
PARTITION p8 VALUES LESS THAN ('q','AE'),
PARTITION p9 VALUES LESS THAN ('s','AE'),
PARTITION p10 VALUES LESS THAN ('u','AE'),
PARTITION p11 VALUES LESS THAN ('w','AE'),
PARTITION p12 VALUES LESS THAN ('y','AE'),
PARTITION p13 VALUES LESS THAN ('a','AK'),
PARTITION p14 VALUES LESS THAN ('c','AK'),
PARTITION p15 VALUES LESS THAN ('e','AK'),
PARTITION p16 VALUES LESS THAN ('g','AK'),
PARTITION p17 VALUES LESS THAN ('i','AK'),
PARTITION p18 VALUES LESS THAN ('k','AK'),
PARTITION p19 VALUES LESS THAN ('m','AK'),
PARTITION p20 VALUES LESS THAN ('o','AK'),
PARTITION p21 VALUES LESS THAN ('q','AK'),
PARTITION p22 VALUES LESS THAN ('s','AK'),
PARTITION p23 VALUES LESS THAN ('u','AK'),
PARTITION p24 VALUES LESS THAN ('w','AK'),
PARTITION p25 VALUES LESS THAN ('y','AK'),
PARTITION p26 VALUES LESS THAN ('a','AL'),
PARTITION p27 VALUES LESS THAN ('c','AL'),
PARTITION p28 VALUES LESS THAN ('e','AL'),
PARTITION p29 VALUES LESS THAN ('g','AL'),
PARTITION p30 VALUES LESS THAN ('i','AL'),
PARTITION p31 VALUES LESS THAN ('k','AL'),
PARTITION p32 VALUES LESS THAN ('m','AL'),
PARTITION p33 VALUES LESS THAN ('o','AL'),
PARTITION p34 VALUES LESS THAN ('q','AL'),
PARTITION p35 VALUES LESS THAN ('s','AL'),
PARTITION p36 VALUES LESS THAN ('u','AL'),
PARTITION p37 VALUES LESS THAN ('w','AL'),
PARTITION p38 VALUES LESS THAN ('y','AL'),
PARTITION p39 VALUES LESS THAN ('a','AR'),
PARTITION p40 VALUES LESS THAN ('c','AR'),
PARTITION p41 VALUES LESS THAN ('e','AR'),
PARTITION p42 VALUES LESS THAN ('g','AR'),
PARTITION p43 VALUES LESS THAN ('i','AR'),
PARTITION p44 VALUES LESS THAN ('k','AR'),
PARTITION p45 VALUES LESS THAN ('m','AR'),
PARTITION p46 VALUES LESS THAN ('o','AR'),
PARTITION p47 VALUES LESS THAN ('q','AR'),
PARTITION p48 VALUES LESS THAN ('s','AR'),
PARTITION p49 VALUES LESS THAN ('u','AR'),
PARTITION p50 VALUES LESS THAN ('w','AR').....
However, this fails to work with this error:
ERROR 1493 (HY000): VALUES LESS THAN value must be strictly increasing for each partition
What would be a valid solution for partitioning this table?
(state, city)
. It seems you want the partitions in that alphabetical order.