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
8586
February 28, 2011 07:18PM
2913
February 28, 2011 08:43PM
Re: Partition on day of year
4126
March 01, 2011 12:53AM
2597
March 01, 2011 10:33PM
2472
March 02, 2011 10:00AM
2087
March 02, 2011 11:16AM
2260
March 03, 2011 09:47PM
2692
March 04, 2011 08:58AM
2122
March 04, 2011 10:45AM
2667
March 04, 2011 08:23PM
1850
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.