Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-791

LP:998130 - Avoid copying on REORGANIZE PARTITION where possible

    XMLWordPrintable

Details

    • Task
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • None
    • None

    Description

      When modifying a range partition using ALTER TABLE...REORGANIZE PARTITION it may happen that all rows from the original partition end up in the same new partition. In this case the underlying table could simply be reused intead of being copied over as it happens now.

      E.g.

      CREATE TABLE `t1` (
      `id` int auto_increment primary key,
      ) ENGINE=InnoDB
      PARTITION BY RANGE (id)
      (PARTITION p1 VALUES LESS THAN (1500000) ENGINE = InnoDB,
      PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = InnoDB)
      ;
       
      INSERT INTO t1 SELECT NULL;
      INSERT INTO t1 SELECT NULL FROM t1; -- repeat until > 1 million affected rows are reported 
       
      SELECT max(id) FROM t1; -- verify that number of rows is somehere between 1.6 and 2.9 million
       
      ALTER TABLE t1 REORGANIZE PARTITION p2 INTO (
        PARTITION p2 VALUES LESS THAN (3000000),
        PARTITION p3 VALUES LESS THAN MAXVALUE
      );

      All rows from the original p2 will end up in the new p2 anyway, so the REORGANIZE could just create the new empty p3 partition and modify the top level partition meta information, but the operation is actually taking quite some time as it simply seems to copy over all data from the old p2 partition to the new one ...

      Attachments

        Activity

          People

            Unassigned Unassigned
            hholzgra Hartmut Holzgraefe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.