Home  >  Q&A  >  body text

Mysql partition error, and how to optimize the novel subscription table?

CREATE TABLE `yy_subscribe2` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(10) unsigned NOT NULL comment '用户id',
  `book_id` int(10) unsigned NOT NULL comment '小说id',
  `chapter_id` int(10) unsigned NOT NULL comment '章节id',
  PRIMARY KEY (`id`),
  key book_id(book_id),
  key user_id(user_id),
  key chapter_id(chapter_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8  
PARTITION BY RANGE (user_id) 
( 
    PARTITION s0 values LESS THAN (100000),
    PARTITION s1 values LESS THAN (200000),
    PARTITION s2 values LESS THAN (300000),
    PARTITION s3 values LESS THAN (400000),
    PARTITION s4 values LESS THAN (500000),
    PARTITION s5 values LESS THAN (600000),
    PARTITION s6 values LESS THAN (700000),
    PARTITION s7 values LESS THAN (800000),
    PARTITION s8 values LESS THAN (900000),
    PARTITION s9 values LESS THAN (1000000),
    PARTITION s10 values LESS THAN (1100000),
    PARTITION s11 values LESS THAN (1200000),
    PARTITION s12 values LESS THAN (1300000),
    PARTITION s13 values LESS THAN (1400000), 
    PARTITION s999 values LESS THAN MAXVALUE
);

mysql reports this error when creating a partition: For RANGE partitions each partition must be defined.
what is the reason.

In addition, this is a chapter subscription form for the novel. Used to record which chapter of which book the user has subscribed to. There are currently 3000W pieces of data. Indexing has already been done. Will the planned use of partitions have an effect on subsequent data growth? Or use other methods without partitioning?

仅有的幸福仅有的幸福2734 days ago823

reply all(1)I'll reply

  • 滿天的星座

    滿天的星座2017-05-18 10:55:57

    I haven’t played with creating partitions in MySQL yet. Is it possible that you made a typo in the syntax? Check again. In addition, for subscription needs, it seems that it is now recommended to use NoSQL such as redis.

    reply
    0
  • Cancelreply