MySQL mysql数据库自动分区
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2174112/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql database automatic partitioning
提问by Jeff Storey
I have a mysql database table that I want to partition by date, particularly by month & year. However, when new data is added for a new month, I don't want to need to manually update the database.
我有一个 mysql 数据库表,我想按日期分区,特别是按月和年。但是,当为新的月份添加新数据时,我不想需要手动更新数据库。
When I initially create my database, I have data in Nov 09, Dec 09, Jan 10, etc. Now when February starts, I'd like a Feb 10 partition automatically created. Is this possible?
当我最初创建我的数据库时,我有 11 月 9 日、12 月 9 日、1 月 10 日等日期的数据。现在,当 2 月开始时,我希望自动创建一个 2 月 10 日的分区。这可能吗?
采纳答案by Nick Craver
There are a few solutions out there, if you want a total solution, check this post out on kickingtyres. It's a basic combination of a stored procedure handling the partition analysis and creation (with some logging!).
有一些解决方案,如果你想要一个完整的解决方案,请查看kickingtyres 上的这篇文章。它是处理分区分析和创建(带有一些日志记录!)的存储过程的基本组合。
All you need to do is adjust it to your partition type (the example uses a bigint partition) and schedule the procedure to run with the MySQL Event Scheduler.
您需要做的就是将其调整为您的分区类型(该示例使用 bigint 分区)并安排该过程与 MySQL Event Scheduler 一起运行。
回答by cristian
I will do what the other done (post a link) Quick Introdunction to MySQL Partitioning
我会做其他人所做的(发布链接)MySQL 分区快速介绍
(look at page 50 for what you need - partition by date)
Edit: I reread your post more carefully - if you want to change partitions by month why don't you create a Mysql event
that does that
(看50页,你需要什么-按日期分区)编辑:我重新读您的文章-如果你每月要改变分区你为什么不建立一个MySQL event
,做的是
回答by user262976
yes, you might like the enhanced partitioning functionality in 5.5:
是的,您可能会喜欢 5.5 中增强的分区功能:
http://dev.mysql.com/tech-resources/articles/mysql_55_partitioning.html
http://dev.mysql.com/tech-resources/articles/mysql_55_partitioning.html