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

Optimizer uses all partitions during an update in MariaDB 10.6.x but not in 10.2.x

Details

    Description

      We used 10.2.x for a long time, where update commands on a partition were quite fast.
      The third partition archive is very large and should not be part of the update. MariaDB 10.6.x uses all partitions on UPDATE, not on SELECT.

      Simple Test

      USE test;
      DROP TABLE IF EXISTS src;
      DROP TABLE IF EXISTS trg;
       
      CREATE TABLE src (
        part INT(1), a INT(1), 
        b INT(1), 
        PRIMARY KEY (a,part), 
        INDEX b (b,part)
      )ENGINE=InnoDB 
      PARTITION BY LIST (part) ( 
        PARTITION Current VALUES IN (0), 
        PARTITION Relevant VALUES IN (1), 
        PARTITION Archive VALUES IN (2)
      );
       
      CREATE TABLE trg LIKE src;
      INSERT INTO src (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);
      INSERT INTO trg (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);
       
      EXPLAIN FORMAT=JSON 
      UPDATE trg JOIN src USING(a) SET trg.part=1 
      WHERE trg.part=1 AND src.part=2 ;
      

      Attachments

        Issue Links

          Activity

            SvenH Sven Heidrich created issue -
            SvenH Sven Heidrich made changes -
            Field Original Value New Value
            Description We used 10.2.x for a long time, where update commands on a partition were quite fast.
            The third partition archive is very large and should not be part of the update. MariaDB 10.6.x uses all partitions on UPDATE, not on SELECT.

            {noformat:title=Simple Test}
            USE test;
            DROP TABLE IF EXISTS src;
            DROP TABLE IF EXISTS trg;

            CREATE TABLE src ( part INT(1), a INT(1), b INT(1), PRIMARY KEY (a,part), INDEX b (b,part))ENGINE=InnoDB
            PARTITION BY LIST (part) ( PARTITION Current VALUES IN (0), PARTITION Relevant VALUES IN (1), PARTITION Archive VALUES IN (2));

            CREATE TABLE trg LIKE src;
            INSERT INTO src (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);
            INSERT INTO trg (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);

            EXPLAIN FORMAT=JSON UPDATE trg JOIN src USING(a) SET trg.part=1 WHERE trg.part=1 AND src.part=2 ;
            {noformat}

            We used 10.2.x for a long time, where update commands on a partition were quite fast.
            The third partition archive is very large and should not be part of the update. MariaDB 10.6.x uses all partitions on UPDATE, not on SELECT.
             !C25636c.png|thumbnail!
            {noformat:title=Simple Test}
            USE test;
            DROP TABLE IF EXISTS src;
            DROP TABLE IF EXISTS trg;

            CREATE TABLE src ( part INT(1), a INT(1), b INT(1), PRIMARY KEY (a,part), INDEX b (b,part))ENGINE=InnoDB
            PARTITION BY LIST (part) ( PARTITION Current VALUES IN (0), PARTITION Relevant VALUES IN (1), PARTITION Archive VALUES IN (2));

            CREATE TABLE trg LIKE src;
            INSERT INTO src (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);
            INSERT INTO trg (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);

            EXPLAIN FORMAT=JSON UPDATE trg JOIN src USING(a) SET trg.part=1 WHERE trg.part=1 AND src.part=2 ;
            {noformat}

            SvenH Sven Heidrich made changes -
            Description We used 10.2.x for a long time, where update commands on a partition were quite fast.
            The third partition archive is very large and should not be part of the update. MariaDB 10.6.x uses all partitions on UPDATE, not on SELECT.
             !C25636c.png|thumbnail!
            {noformat:title=Simple Test}
            USE test;
            DROP TABLE IF EXISTS src;
            DROP TABLE IF EXISTS trg;

            CREATE TABLE src ( part INT(1), a INT(1), b INT(1), PRIMARY KEY (a,part), INDEX b (b,part))ENGINE=InnoDB
            PARTITION BY LIST (part) ( PARTITION Current VALUES IN (0), PARTITION Relevant VALUES IN (1), PARTITION Archive VALUES IN (2));

            CREATE TABLE trg LIKE src;
            INSERT INTO src (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);
            INSERT INTO trg (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);

            EXPLAIN FORMAT=JSON UPDATE trg JOIN src USING(a) SET trg.part=1 WHERE trg.part=1 AND src.part=2 ;
            {noformat}

            We used 10.2.x for a long time, where update commands on a partition were quite fast.
            The third partition archive is very large and should not be part of the update. MariaDB 10.6.x uses all partitions on UPDATE, not on SELECT.
             !C25636c.png|thumbnail! !C25636d.png|thumbnail!
            {noformat:title=Simple Test}
            USE test;
            DROP TABLE IF EXISTS src;
            DROP TABLE IF EXISTS trg;

            CREATE TABLE src ( part INT(1), a INT(1), b INT(1), PRIMARY KEY (a,part), INDEX b (b,part))ENGINE=InnoDB
            PARTITION BY LIST (part) ( PARTITION Current VALUES IN (0), PARTITION Relevant VALUES IN (1), PARTITION Archive VALUES IN (2));

            CREATE TABLE trg LIKE src;
            INSERT INTO src (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);
            INSERT INTO trg (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);

            EXPLAIN FORMAT=JSON UPDATE trg JOIN src USING(a) SET trg.part=1 WHERE trg.part=1 AND src.part=2 ;
            {noformat}

            SvenH Sven Heidrich made changes -
            Description We used 10.2.x for a long time, where update commands on a partition were quite fast.
            The third partition archive is very large and should not be part of the update. MariaDB 10.6.x uses all partitions on UPDATE, not on SELECT.
             !C25636c.png|thumbnail! !C25636d.png|thumbnail!
            {noformat:title=Simple Test}
            USE test;
            DROP TABLE IF EXISTS src;
            DROP TABLE IF EXISTS trg;

            CREATE TABLE src ( part INT(1), a INT(1), b INT(1), PRIMARY KEY (a,part), INDEX b (b,part))ENGINE=InnoDB
            PARTITION BY LIST (part) ( PARTITION Current VALUES IN (0), PARTITION Relevant VALUES IN (1), PARTITION Archive VALUES IN (2));

            CREATE TABLE trg LIKE src;
            INSERT INTO src (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);
            INSERT INTO trg (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);

            EXPLAIN FORMAT=JSON UPDATE trg JOIN src USING(a) SET trg.part=1 WHERE trg.part=1 AND src.part=2 ;
            {noformat}

            We used 10.2.x for a long time, where update commands on a partition were quite fast.
            The third partition archive is very large and should not be part of the update. MariaDB 10.6.x uses all partitions on UPDATE, not on SELECT.

             !C25636c.png|thumbnail! !C25636d.png|thumbnail!
            {noformat:title=Simple Test}
            USE test;
            DROP TABLE IF EXISTS src;
            DROP TABLE IF EXISTS trg;

            CREATE TABLE src ( part INT(1), a INT(1), b INT(1), PRIMARY KEY (a,part), INDEX b (b,part))ENGINE=InnoDB
            PARTITION BY LIST (part) ( PARTITION Current VALUES IN (0), PARTITION Relevant VALUES IN (1), PARTITION Archive VALUES IN (2));

            CREATE TABLE trg LIKE src;
            INSERT INTO src (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);
            INSERT INTO trg (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);

            EXPLAIN FORMAT=JSON UPDATE trg JOIN src USING(a) SET trg.part=1 WHERE trg.part=1 AND src.part=2 ;
            {noformat}

            SvenH Sven Heidrich made changes -
            SvenH Sven Heidrich made changes -
            SvenH Sven Heidrich made changes -
            SvenH Sven Heidrich made changes -
            Affects Version/s 10.6 [ 24028 ]
            Affects Version/s 10.6.7 [ 26812 ]
            alice Alice Sherepa made changes -
            Affects Version/s 10.3 [ 22126 ]
            Affects Version/s 10.4 [ 22408 ]
            Affects Version/s 10.5 [ 23123 ]
            Affects Version/s 10.7 [ 24805 ]
            alice Alice Sherepa made changes -
            Assignee Sergei Petrunia [ psergey ]
            alice Alice Sherepa made changes -
            Fix Version/s 10.3 [ 22126 ]
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.7 [ 24805 ]
            psergei Sergei Petrunia made changes -
            Assignee Sergei Petrunia [ psergey ] Oleg Smirnov [ JIRAUSER50405 ]
            oleg.smirnov Oleg Smirnov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            psergei Sergei Petrunia made changes -
            Description We used 10.2.x for a long time, where update commands on a partition were quite fast.
            The third partition archive is very large and should not be part of the update. MariaDB 10.6.x uses all partitions on UPDATE, not on SELECT.

             !C25636c.png|thumbnail! !C25636d.png|thumbnail!
            {noformat:title=Simple Test}
            USE test;
            DROP TABLE IF EXISTS src;
            DROP TABLE IF EXISTS trg;

            CREATE TABLE src ( part INT(1), a INT(1), b INT(1), PRIMARY KEY (a,part), INDEX b (b,part))ENGINE=InnoDB
            PARTITION BY LIST (part) ( PARTITION Current VALUES IN (0), PARTITION Relevant VALUES IN (1), PARTITION Archive VALUES IN (2));

            CREATE TABLE trg LIKE src;
            INSERT INTO src (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);
            INSERT INTO trg (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);

            EXPLAIN FORMAT=JSON UPDATE trg JOIN src USING(a) SET trg.part=1 WHERE trg.part=1 AND src.part=2 ;
            {noformat}

            We used 10.2.x for a long time, where update commands on a partition were quite fast.
            The third partition archive is very large and should not be part of the update. MariaDB 10.6.x uses all partitions on UPDATE, not on SELECT.

             !C25636c.png|thumbnail! !C25636d.png|thumbnail!
            {noformat:title=Simple Test}
            USE test;
            DROP TABLE IF EXISTS src;
            DROP TABLE IF EXISTS trg;

            CREATE TABLE src (
              part INT(1), a INT(1),
              b INT(1),
              PRIMARY KEY (a,part),
              INDEX b (b,part)
            )ENGINE=InnoDB
            PARTITION BY LIST (part) (
              PARTITION Current VALUES IN (0),
              PARTITION Relevant VALUES IN (1),
              PARTITION Archive VALUES IN (2)
            );

            CREATE TABLE trg LIKE src;
            INSERT INTO src (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);
            INSERT INTO trg (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2);

            EXPLAIN FORMAT=JSON
            UPDATE trg JOIN src USING(a) SET trg.part=1
            WHERE trg.part=1 AND src.part=2 ;
            {noformat}

            oleg.smirnov Oleg Smirnov made changes -
            Assignee Oleg Smirnov [ JIRAUSER50405 ] Sergei Petrunia [ psergey ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            psergei Sergei Petrunia made changes -
            Status In Review [ 10002 ] Stalled [ 10000 ]
            psergei Sergei Petrunia made changes -
            Assignee Sergei Petrunia [ psergey ] Oleg Smirnov [ JIRAUSER50405 ]
            oleg.smirnov Oleg Smirnov made changes -
            Fix Version/s 10.3.35 [ 27512 ]
            Fix Version/s 10.4.25 [ 27510 ]
            Fix Version/s 10.5.16 [ 27508 ]
            Fix Version/s 10.6.8 [ 27506 ]
            Fix Version/s 10.7.4 [ 27504 ]
            Fix Version/s 10.8.3 [ 27502 ]
            Fix Version/s 10.3 [ 22126 ]
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.7 [ 24805 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            dbart Daniel Bartholomew made changes -
            Fix Version/s 10.3.36 [ 27513 ]
            Fix Version/s 10.4.26 [ 27511 ]
            Fix Version/s 10.5.17 [ 27509 ]
            Fix Version/s 10.6.9 [ 27507 ]
            Fix Version/s 10.7.5 [ 27505 ]
            Fix Version/s 10.8.4 [ 27503 ]
            Fix Version/s 10.8.3 [ 27502 ]
            Fix Version/s 10.7.4 [ 27504 ]
            Fix Version/s 10.6.8 [ 27506 ]
            Fix Version/s 10.5.16 [ 27508 ]
            Fix Version/s 10.4.25 [ 27510 ]
            Fix Version/s 10.3.35 [ 27512 ]

            People

              oleg.smirnov Oleg Smirnov
              SvenH Sven Heidrich
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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