MySQL Forums
Forum List  »  Partitioning

Re: Partition on day of year
Posted by: Shantanu Oak
Date: March 01, 2011 12:53AM

More than 700 partitions are theoretically possible, but are not recommended.
The best plan would be to create monthly partitions. (24 for 2 years)

You can use the shell script available here...

http://forge.mysql.com/tools/tool.php?id=200
_____

Create a table in the test database with the name "date_helper"

mysql> CREATE TABLE test.date_helper (
id INT NOT NULL,
to_timestamp datetime
);

Run the shell script and feed the output to mysql

unix> sh mydate.sh | mysql -uUser -pPassWd test

_____

The altered table will look something like this:

CREATE TABLE `date_helper` (
`id` int(11) NOT NULL,
`to_timestamp` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (to_days(to_timestamp))
(PARTITION January2010 VALUES IN (734138,734139,734140, ...) ENGINE = InnoDB,
PARTITION February2010 VALUES IN (734169,734170,734171,... ) ENGINE = InnoDB,
...
...
PARTITION November2011 VALUES IN (734807,734808,734809,...) ENGINE = InnoDB,
PARTITION December2011 VALUES IN (734837,734838,734839,...) ENGINE = InnoDB) */

_____

You can change the number of years as well as the starting month while running the script. If you want 3 years (365*3) partition starting from Jan 1990, use the following syntax:

sh mydate.sh 1990-01-01 1096

Options: ReplyQuote


Subject
Views
Written By
Posted
8451
February 28, 2011 07:18PM
2865
February 28, 2011 08:43PM
Re: Partition on day of year
4066
March 01, 2011 12:53AM
2544
March 01, 2011 10:33PM
2426
March 02, 2011 10:00AM
2029
March 02, 2011 11:16AM
2203
March 03, 2011 09:47PM
2639
March 04, 2011 08:58AM
2084
March 04, 2011 10:45AM
2620
March 04, 2011 08:23PM
1807
March 02, 2011 02:58AM


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.