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

Apparently UPDATE and DELETE don't use partition pruning

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 10.0(EOL)
    • N/A
    • Partitioning
    • None

    Description

      CREATE OR REPLACE TABLE t
      (
      	id INT UNSIGNED NOT NULL AUTO_INCREMENT,
      	timestamp DATETIME NOT NULL,
      	PRIMARY KEY (id, timestamp)
      )
      	ENGINE = InnoDB
      PARTITION BY RANGE (YEAR(timestamp))
      (
      	PARTITION p0 VALUES LESS THAN (2010),
      	PARTITION p1 VALUES LESS THAN (2015),
      	PARTITION p2 VALUES LESS THAN (2020)
      );
       
      MariaDB [test]> EXPLAIN PARTITIONS UPDATE t SET timestamp = NOW() WHERE timestamp < 2000;
      +------+-------------+-------+------------+-------+---------------+---------+---------+------+------+---------------------------+
      | id   | select_type | table | partitions | type  | possible_keys | key     | key_len | ref  | rows | Extra                     |
      +------+-------------+-------+------------+-------+---------------+---------+---------+------+------+---------------------------+
      |    1 | SIMPLE      | t     | p0,p1,p2   | index | NULL          | PRIMARY | 12      | NULL |    3 | Using where; Using buffer |
      +------+-------------+-------+------------+-------+---------------+---------+---------+------+------+---------------------------+
      1 row in set (0.00 sec)
       
      MariaDB [test]> EXPLAIN PARTITIONS DELETE FROM t WHERE timestamp < 2000;
      +------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+
      | id   | select_type | table | partitions | type | possible_keys | key  | key_len | ref  | rows | Extra       |
      +------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+
      |    1 | SIMPLE      | t     | p0,p1,p2   | ALL  | NULL          | NULL | NULL    | NULL |    3 | Using where |
      +------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+
      1 row in set (0.01 sec)

      Only tested on 10.0.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              f_razzoli Federico Razzoli
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.