为什么我不能插入范围列分区

时间:2019-09-02 16:51:58

标签: mysql partitioning

我有一个包含大量数据的表,并且该数据已经拆分为多个分区。现在,我想为新类型的数据集添加新分区。

当前表如下:

create table audit_log
(
    id bigint unsigned auto_increment,
    inserted_at datetime default '0000-00-00 00:00:00' not null,
    eventType varchar(50) not null,
    eventTableName varchar(255) default '' not null,
    entityId int unsigned null,
    matchId int unsigned null,
    userId int unsigned null,
    route varchar(255) null,
    changes longtext null,
    primary key (id, eventTableName, inserted_at)
)
collate=utf8_unicode_ci;

根据eventTableNameinserted_at列有几个分区:

ALTER TABLE audit_log PARTITION BY RANGE COLUMNS (eventTableName, inserted_at)  (
    PARITION day_referee_statistics_20190902 VALUES LESS THAN ('referee_statistics','2019-09-03'),
    PARITION day_referee_statistics_20190903 VALUES LESS THAN ('referee_statistics','2019-09-04'),
    PARITION referee_future VALUES LESS THAN ('referee_statistics',MAXVALUE),
    PARITION day_team_statistics_20190902 VALUES LESS THAN ('team_statistics','2019-09-03'),
    PARITION day_team_statistics_20190903 VALUES LESS THAN ('team_statistics','2019-09-04'),
    PARITION team_statistics_future VALUES LESS THAN ('team_statistics',MAXVALUE),
    PARITION future VALUES LESS THAN (MAXVALUE, MAXVALUE);

还有很多其他分区...

现在,我想为要审核的新表添加一个新分区:results_future分区。首先,我尝试替换将来的分区,但是失败了,因为其他分区之间的价格更高。然后我对它们进行了排序,但仍然出现相同的错误:

ALTER TABLE audit_log REORGANIZE PARTITION future_team_statistics INTO (
    PARTITION future_results VALUES LESS THAN ('results',MAXVALUE),
    PARTITION future_team_statistics VALUES LESS THAN ('team_statistics',MAXVALUE)
)

失败:

  

一般错误:每个分区必须严格增加1493个值以下

1 个答案:

答案 0 :(得分:0)

新分区和MAXVALUE分区之间的最小分区不是team_statistics_future-在这种情况下,它是day_team_statistics_20190902分区。因此查询将是:

ALTER TABLE audit_log REORGANIZE PARTITION day_team_statistics_20190902 INTO (
    PARTITION future_results VALUES LESS THAN ('results',MAXVALUE),
    PARTITION day_team_statistics_20190902 VALUES LESS THAN ('team_statistics','2019-09-03')
);