MySQL Forums
Forum List  »  Partitioning

How to partition by City \ State
Posted by: Noah Goodrich
Date: December 19, 2012 10:06PM

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?



Edited 1 time(s). Last edit at 12/19/2012 10:40PM by Noah Goodrich.

Options: ReplyQuote


Subject
Views
Written By
Posted
How to partition by City \ State
2360
December 19, 2012 10:06PM
1346
December 20, 2012 10:00PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.