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

Select statement with partition selection against MyISAM table opens all partitions

Details

    • 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23, 10.3.1-1, 10.1.29, 10.1.30, 10.1.31

    Description

      When a user uses partition selection in a SELECT query to only query a particular partition of a MyISAM table, many users would expect the server to only open the data files for that particular partition. In reality, the server opens all data files for the table.

      This bug is related to partition selection in SELECT statements, as defined here:

      http://dev.mysql.com/doc/refman/5.6/en/partitioning-selection.html

      Let's say that we create the following table:

      CREATE TABLE employees  (
          id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
          fname VARCHAR(25) NOT NULL,
          lname VARCHAR(25) NOT NULL,
          store_id INT NOT NULL,
          department_id INT NOT NULL
      ) ENGINE=MyISAM
          PARTITION BY RANGE(id)  (
              PARTITION p0 VALUES LESS THAN (5),
              PARTITION p1 VALUES LESS THAN (10),
              PARTITION p2 VALUES LESS THAN (15),
              PARTITION p3 VALUES LESS THAN MAXVALUE
      );
       
      INSERT INTO employees VALUES
          ('', 'Bob', 'Taylor', 3, 2), ('', 'Frank', 'Williams', 1, 2),
          ('', 'Ellen', 'Johnson', 3, 4), ('', 'Jim', 'Smith', 2, 4),
          ('', 'Mary', 'Jones', 1, 1), ('', 'Linda', 'Black', 2, 3),
          ('', 'Ed', 'Jones', 2, 1), ('', 'June', 'Wilson', 3, 1),
          ('', 'Andy', 'Smith', 1, 3), ('', 'Lou', 'Waters', 2, 4),
          ('', 'Jill', 'Stone', 1, 4), ('', 'Roger', 'White', 3, 2),
          ('', 'Howard', 'Andrews', 1, 2), ('', 'Fred', 'Goldberg', 3, 3),
          ('', 'Barbara', 'Brown', 2, 3), ('', 'Alice', 'Rogers', 2, 2),
          ('', 'Mark', 'Morgan', 3, 3), ('', 'Karen', 'Cole', 3, 2);
      

      And then we execute the following to ensure that the table's data files are closed:

      FLUSH TABLES;
      

      And then we can confirm that the table's data files are not open:

      $ sudo lsof -p `pidof mysqld` | grep employees
      

      And then let's say that we execute the following query:

      SELECT * FROM employees PARTITION (p1);
      

      Most users would expect that the server would only open the data files for partition p1. In reality, it opens all of them:

      $ sudo lsof -p `pidof mysqld` | grep employees
      mysqld  825 mysql   18u   REG              202,2      2048 50336245 /var/lib/mysql/db1/employees#P#p0.MYI
      mysqld  825 mysql   20u   REG              202,2       120 50336246 /var/lib/mysql/db1/employees#P#p0.MYD
      mysqld  825 mysql   23u   REG              202,2      2048 50336247 /var/lib/mysql/db1/employees#P#p1.MYI
      mysqld  825 mysql   24u   REG              202,2       140 50336248 /var/lib/mysql/db1/employees#P#p1.MYD
      mysqld  825 mysql   25u   REG              202,2      2048 50336249 /var/lib/mysql/db1/employees#P#p2.MYI
      mysqld  825 mysql   26u   REG              202,2       148 50336250 /var/lib/mysql/db1/employees#P#p2.MYD
      mysqld  825 mysql   27u   REG              202,2      2048 50336251 /var/lib/mysql/db1/employees#P#p3.MYI
      mysqld  825 mysql   28u   REG              202,2       120 50336252 /var/lib/mysql/db1/employees#P#p3.MYD
      

      Attachments

        Issue Links

          Activity

            GeoffMontee Geoff Montee (Inactive) created issue -
            GeoffMontee Geoff Montee (Inactive) made changes -
            Field Original Value New Value
            Description This bug is related to partition selection in SELECT statements, as defined here:

            http://dev.mysql.com/doc/refman/5.6/en/partitioning-selection.html

            Let's say that we create the following table:

            {noformat}
            CREATE TABLE employees (
                id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
                fname VARCHAR(25) NOT NULL,
                lname VARCHAR(25) NOT NULL,
                store_id INT NOT NULL,
                department_id INT NOT NULL
            ) ENGINE=MyISAM
                PARTITION BY RANGE(id) (
                    PARTITION p0 VALUES LESS THAN (5),
                    PARTITION p1 VALUES LESS THAN (10),
                    PARTITION p2 VALUES LESS THAN (15),
                    PARTITION p3 VALUES LESS THAN MAXVALUE
            );

            INSERT INTO employees VALUES
                ('', 'Bob', 'Taylor', 3, 2), ('', 'Frank', 'Williams', 1, 2),
                ('', 'Ellen', 'Johnson', 3, 4), ('', 'Jim', 'Smith', 2, 4),
                ('', 'Mary', 'Jones', 1, 1), ('', 'Linda', 'Black', 2, 3),
                ('', 'Ed', 'Jones', 2, 1), ('', 'June', 'Wilson', 3, 1),
                ('', 'Andy', 'Smith', 1, 3), ('', 'Lou', 'Waters', 2, 4),
                ('', 'Jill', 'Stone', 1, 4), ('', 'Roger', 'White', 3, 2),
                ('', 'Howard', 'Andrews', 1, 2), ('', 'Fred', 'Goldberg', 3, 3),
                ('', 'Barbara', 'Brown', 2, 3), ('', 'Alice', 'Rogers', 2, 2),
                ('', 'Mark', 'Morgan', 3, 3), ('', 'Karen', 'Cole', 3, 2);
            {noformat}

            And then we execute the following to ensure that the table's data files are closed:

            {noformat}
            FLUSH TABLES;
            {noformat}

            And then we can confirm that the table's data files are not open:

            {noformat}
            $ sudo lsof -p `pidof mysqld` | grep employees
            {noformat}

            And then let's say that we execute the following query:

            {noformat}
            SELECT * FROM employees PARTITION (p1);
            {noformat}

            Most users would expect that the server would only open the data files for partition p1. In reality, it opens all of them:

            {noformat}
            $ sudo lsof -p `pidof mysqld` | grep employees
            mysqld 825 mysql 18u REG 202,2 2048 50336245 /var/lib/mysql/db1/employees#P#p0.MYI
            mysqld 825 mysql 20u REG 202,2 120 50336246 /var/lib/mysql/db1/employees#P#p0.MYD
            mysqld 825 mysql 23u REG 202,2 2048 50336247 /var/lib/mysql/db1/employees#P#p1.MYI
            mysqld 825 mysql 24u REG 202,2 140 50336248 /var/lib/mysql/db1/employees#P#p1.MYD
            mysqld 825 mysql 25u REG 202,2 2048 50336249 /var/lib/mysql/db1/employees#P#p2.MYI
            mysqld 825 mysql 26u REG 202,2 148 50336250 /var/lib/mysql/db1/employees#P#p2.MYD
            mysqld 825 mysql 27u REG 202,2 2048 50336251 /var/lib/mysql/db1/employees#P#p3.MYI
            mysqld 825 mysql 28u REG 202,2 120 50336252 /var/lib/mysql/db1/employees#P#p3.MYD
            {noformat}
            When a user uses partition selection in a SELECT query to only query a particular partition of a MyISAM table, many users would expect the server to only open the data files for that particular partition. In reality, the server opens all data files for the table.

            This bug is related to partition selection in SELECT statements, as defined here:

            http://dev.mysql.com/doc/refman/5.6/en/partitioning-selection.html

            Let's say that we create the following table:

            {noformat}
            CREATE TABLE employees (
                id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
                fname VARCHAR(25) NOT NULL,
                lname VARCHAR(25) NOT NULL,
                store_id INT NOT NULL,
                department_id INT NOT NULL
            ) ENGINE=MyISAM
                PARTITION BY RANGE(id) (
                    PARTITION p0 VALUES LESS THAN (5),
                    PARTITION p1 VALUES LESS THAN (10),
                    PARTITION p2 VALUES LESS THAN (15),
                    PARTITION p3 VALUES LESS THAN MAXVALUE
            );

            INSERT INTO employees VALUES
                ('', 'Bob', 'Taylor', 3, 2), ('', 'Frank', 'Williams', 1, 2),
                ('', 'Ellen', 'Johnson', 3, 4), ('', 'Jim', 'Smith', 2, 4),
                ('', 'Mary', 'Jones', 1, 1), ('', 'Linda', 'Black', 2, 3),
                ('', 'Ed', 'Jones', 2, 1), ('', 'June', 'Wilson', 3, 1),
                ('', 'Andy', 'Smith', 1, 3), ('', 'Lou', 'Waters', 2, 4),
                ('', 'Jill', 'Stone', 1, 4), ('', 'Roger', 'White', 3, 2),
                ('', 'Howard', 'Andrews', 1, 2), ('', 'Fred', 'Goldberg', 3, 3),
                ('', 'Barbara', 'Brown', 2, 3), ('', 'Alice', 'Rogers', 2, 2),
                ('', 'Mark', 'Morgan', 3, 3), ('', 'Karen', 'Cole', 3, 2);
            {noformat}

            And then we execute the following to ensure that the table's data files are closed:

            {noformat}
            FLUSH TABLES;
            {noformat}

            And then we can confirm that the table's data files are not open:

            {noformat}
            $ sudo lsof -p `pidof mysqld` | grep employees
            {noformat}

            And then let's say that we execute the following query:

            {noformat}
            SELECT * FROM employees PARTITION (p1);
            {noformat}

            Most users would expect that the server would only open the data files for partition p1. In reality, it opens all of them:

            {noformat}
            $ sudo lsof -p `pidof mysqld` | grep employees
            mysqld 825 mysql 18u REG 202,2 2048 50336245 /var/lib/mysql/db1/employees#P#p0.MYI
            mysqld 825 mysql 20u REG 202,2 120 50336246 /var/lib/mysql/db1/employees#P#p0.MYD
            mysqld 825 mysql 23u REG 202,2 2048 50336247 /var/lib/mysql/db1/employees#P#p1.MYI
            mysqld 825 mysql 24u REG 202,2 140 50336248 /var/lib/mysql/db1/employees#P#p1.MYD
            mysqld 825 mysql 25u REG 202,2 2048 50336249 /var/lib/mysql/db1/employees#P#p2.MYI
            mysqld 825 mysql 26u REG 202,2 148 50336250 /var/lib/mysql/db1/employees#P#p2.MYD
            mysqld 825 mysql 27u REG 202,2 2048 50336251 /var/lib/mysql/db1/employees#P#p3.MYI
            mysqld 825 mysql 28u REG 202,2 120 50336252 /var/lib/mysql/db1/employees#P#p3.MYD
            {noformat}
            GeoffMontee Geoff Montee (Inactive) made changes -
            GeoffMontee Geoff Montee (Inactive) made changes -
            Labels myisam partitioning myisam partitioning upstream
            elenst Elena Stepanova made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]

            Reproducible on MySQL 5.6, 5.7.

            elenst Elena Stepanova added a comment - Reproducible on MySQL 5.6, 5.7.
            elenst Elena Stepanova made changes -
            Fix Version/s 10.2 [ 14601 ]
            Affects Version/s 10.0 [ 16000 ]
            Affects Version/s 10.1 [ 16100 ]
            Affects Version/s 10.2 [ 14601 ]
            holyfoot Alexey Botchkov made changes -
            Assignee Alexey Botchkov [ holyfoot ]
            holyfoot Alexey Botchkov made changes -
            Status Confirmed [ 10101 ] In Progress [ 3 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.1.19 [ 109 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Rank Ranked higher
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.1.19 [ 109 ] 10.1.19, 10.1.20 [ 109, 119 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Rank Ranked higher
            serg Sergei Golubchik made changes -
            Fix Version/s 10.2 [ 14601 ]
            serg Sergei Golubchik made changes -
            Affects Version/s 10.2 [ 14601 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.1.19, 10.1.20 [ 109, 119 ] 10.1.19, 10.1.20, 10.1.21 [ 109, 119, 130 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.1.19, 10.1.20, 10.1.21 [ 109, 119, 130 ] 10.1.19, 10.1.20, 10.2.4-1 [ 109, 119, 132 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Rank Ranked lower
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.1.19, 10.1.20, 10.2.4-1 [ 109, 119, 132 ] 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2 [ 109, 119, 132, 134 ]
            serg Sergei Golubchik made changes -
            Sprint 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2 [ 109, 119, 132, 134 ] 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.0.30 [ 109, 119, 132, 134, 140 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.0.30 [ 109, 119, 132, 134, 140 ] 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22 [ 109, 119, 132, 134, 143 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22 [ 109, 119, 132, 134, 143 ] 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23 [ 109, 119, 132, 134, 143, 154 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Rank Ranked lower
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23 [ 109, 119, 132, 134, 143, 154 ] 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23, 10.1.24 [ 109, 119, 132, 134, 143, 154, 161 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Sprint 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23, 10.1.24 [ 109, 119, 132, 134, 143, 154, 161 ] 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23, 10.3.1-1 [ 109, 119, 132, 134, 143, 154, 164 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Rank Ranked lower
            holyfoot Alexey Botchkov added a comment - Patch proposal: http://lists.askmonty.org/pipermail/commits/2017-June/011221.html
            holyfoot Alexey Botchkov made changes -
            Assignee Alexey Botchkov [ holyfoot ] Sergei Golubchik [ serg ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            holyfoot Alexey Botchkov added a comment - - edited Updated patch. http://lists.askmonty.org/pipermail/commits/2017-June/011237.html
            serg Sergei Golubchik made changes -
            Sprint 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23, 10.3.1-1 [ 109, 119, 132, 134, 143, 154, 164 ] 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23, 10.3.1-1, 10.1.29 [ 109, 119, 132, 134, 143, 154, 164, 202 ]
            serg Sergei Golubchik made changes -
            Sprint 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23, 10.3.1-1, 10.1.29 [ 109, 119, 132, 134, 143, 154, 164, 202 ] 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23, 10.3.1-1, 10.1.29, 10.1.30 [ 109, 119, 132, 134, 143, 154, 164, 202, 215 ]
            serg Sergei Golubchik made changes -
            Rank Ranked higher
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Alexey Botchkov [ holyfoot ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            holyfoot Alexey Botchkov added a comment - http://lists.askmonty.org/pipermail/commits/2017-December/011736.html
            holyfoot Alexey Botchkov made changes -
            Assignee Alexey Botchkov [ holyfoot ] Sergei Golubchik [ serg ]
            Status Stalled [ 10000 ] In Review [ 10002 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.3 [ 22126 ]
            Fix Version/s 10.1 [ 16100 ]
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Alexey Botchkov [ holyfoot ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            holyfoot Alexey Botchkov made changes -
            Sprint 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23, 10.3.1-1, 10.1.29, 10.1.30 [ 109, 119, 132, 134, 143, 154, 164, 202, 215 ] 10.1.19, 10.1.20, 10.2.4-1, 10.2.4-2, 10.1.22, 10.1.23, 10.3.1-1, 10.1.29, 10.1.30, 10.1.31 [ 109, 119, 132, 134, 143, 154, 164, 202, 215, 225 ]
            holyfoot Alexey Botchkov made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            holyfoot Alexey Botchkov added a comment - The final patch. http://lists.askmonty.org/pipermail/commits/2018-January/011911.html
            holyfoot Alexey Botchkov made changes -
            issue.field.resolutiondate 2018-01-29 07:32:41.0 2018-01-29 07:32:41.475
            holyfoot Alexey Botchkov made changes -
            Fix Version/s 10.3.5 [ 22905 ]
            Fix Version/s 10.3 [ 22126 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            marko Marko Mäkelä made changes -
            serg Sergei Golubchik made changes -
            midenok Aleksey Midenkov made changes -
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 78000 ] MariaDB v4 [ 151090 ]
            mariadb-jira-automation Jira Automation (IT) made changes -
            Zendesk Related Tickets 152974

            People

              holyfoot Alexey Botchkov
              GeoffMontee Geoff Montee (Inactive)
              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.