duanbu4962 2018-06-18 12:33
浏览 55

使用JSON值在数据库表上添加分区

I have an existing database with millions of rows which don't have a partition. I can alter it to add partition, however, the column that I wanted to add partition with contains JSON value and I need to extract that first.

ALTER TABLE api_backup_records 
PARTITION BY RANGE(CAST(JSON_EXTRACT(custom_data, '$.customer_id') AS UNSIGNED))(
PARTITION cus10000 VALUES LESS THAN (10000),
PARTITION cus20000 VALUES LESS THAN (20000),
PARTITION cus30000 VALUES LESS THAN (30000),
PARTITION cus40000 VALUES LESS THAN (40000),
PARTITION cus50000 VALUES LESS THAN (50000),
PARTITION cus60000 VALUES LESS THAN (60000),
PARTITION cus70000 VALUES LESS THAN (70000),
PARTITION cus80000 VALUES LESS THAN (80000),
PARTITION cus90000 VALUES LESS THAN (90000),
PARTITION cusmax VALUES LESS THAN MAXVALUE)

I'm getting an error #1564 - This partition function is not allowed, of which I believe is because of the JSON_EXTRACT function which is not allowed in partitioning. I tried to alter the table by adding a new column with generated value based off of the JSON_EXTRACT, however that isn't supported on MongoDB.

I am wanting to easily search a Customer ID's (customer id being located on the JSON value of custom_data column [this is a custom data, so we need this to remain as a JSON since this will be a dynamic column]) record by partitioning it.

Thank you so much for helping.

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥15 stable diffusion
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条