分区表自动维护 mysql_分区自动管理与维护——MySQL Partition Manager

可以发现MPM还是有一些局限性,特别是分区字段只能是INT类型表示的时间,这对于习惯使用类型datetime作分区字段的同学来说,不得不说是一个打击。话说,Yahoo时间都用unix_timestamp()转化?

接着看下分区配置表:

CREATE TABLE `partition_manager_settings` (

`table` varchar(64) NOT NULL COMMENT 'table name',

`column` varchar(64) NOT NULL COMMENT 'numeric column with time info',

`granularity` int(10) unsigned NOT NULL COMMENT 'granularity of column, i.e. 1=seconds, 60=minutes...',

`increment` int(10) unsigned NOT NULL COMMENT 'seconds per individual partition',

`retain` int(10) unsigned NULL COMMENT 'seconds of data to retain, null for infinite',

`buffer` int(10) unsigned NULL COMMENT 'seconds of empty future partitions to create',

PRIMARY KEY (`table`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=Dynamic;

CREATE TABLE `partition_manager_settings` (

`table` varchar(64) NOT NULL COMMENT 'table name',

`column` varchar(64) NOT NULL COMMENT 'numeric column with time info',

`granularity` int(10) unsigned NOT NULL COMMENT 'granularity of column, i.e. 1=seconds, 60=minutes...',

`increment` int(10) unsigned NOT NULL COMMENT 'seconds per individual partition',

`retain` int(10) unsigned NULL COMMENT 'seconds of data to retain, null for infinite',

`buffer` int(10) unsigned NULL COMMENT 'seconds of empty future partitions to create',

PRIMARY KEY (`table`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=Dynamic;

有了上述这些内容,就能进行分区的自动维护了。接着就是通过存储过程partition_manager进行分区的维护,包括将表转化为分区表、创建新分区、删除老分区。而事件run_partition_manager就是用来进行定时任务设置。

Inside君对整个脚本进行了注释,感兴趣的同学可以点击下方的原文阅读进行查看。

最后,老规矩:“转发文章,手有余香。点击广告,来年加薪”。

当然,还有提前祝小伙伴们中秋节快乐~~~~

猜你喜欢

有态度的MySQL社区

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值