I have a database with a date column having datatype as date. I am using
The table is expected to have 10k rows each day. I want to create partition on the table on year range and then sub partitions on months of that particular year.
I have tried is,
ALTER TABLE nav_master PARTITION BY RANGE( YEAR(nav_date) ) SUBPARTITION BY HASH( MONTH(nav_date) ) SUBPARTITIONS 12 ( PARTITION january VALUES LESS THAN (2), PARTITION february VALUES LESS THAN (3), PARTITION march VALUES LESS THAN (4), PARTITION april VALUES LESS THAN (5), PARTITION may VALUES LESS THAN (6), PARTITION june VALUES LESS THAN (7), PARTITION july VALUES LESS THAN (8), PARTITION august VALUES LESS THAN (9), PARTITION september VALUES LESS THAN (10), PARTITION october VALUES LESS THAN (11), PARTITION november VALUES LESS THAN (12), PARTITION december VALUES LESS THAN (13) );
I am able to execute the above query on empty table. But when I insert or when I execute the above query in same table with some data I get the below error.
#1526 - Table has no partition for value 2014
Not able to understand what the exact error is.
Also let me know if sub partitions help in better optimizing the tables or I should just go with partitions?
Update: I was indeed able to create the partition. The issue now is that there is a NULL partition created. When I had ensured there is no null dates and also all the date conditions were handled while making partitions.
Question is how can I see what data has gone to NULL partition? So that I can get an idea on what the problem is.
I am getting a null partition name using this query.
SELECT PARTITION_NAME, TABLE_ROWS, PARTITION_EXPRESSION, PARTITION_DESCRIPTION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 'nav_master' limit 0,180
Using this query to get all rows in partition, question is what to pass as partition name for null?
SELECT count(*) FROM nav_master PARTITION(??);