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 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
    • ¥20 matlab yalmip kkt 双层优化问题
    • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
    • ¥88 实在没有想法,需要个思路
    • ¥15 MATLAB报错输入参数太多