[MDEV-8982] Apparently UPDATE and DELETE don't use partition pruning Created: 2015-10-22  Updated: 2015-11-02  Resolved: 2015-11-02

Status: Closed
Project: MariaDB Server
Component/s: Partitioning
Affects Version/s: 10.0
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Federico Razzoli Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-8983 EXPLAIN PARTITIONS INSERT doesn't sho... Confirmed

 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.



 Comments   
Comment by Federico Razzoli [ 2015-10-22 ]

Sorry, this is not the bug - my queries were clearly wrong. Linked bug (MDEV-8983) remains valid, I think.

Comment by Sergei Golubchik [ 2015-11-02 ]

Should this one be closed?

Comment by Federico Razzoli [ 2015-11-02 ]

Yes. Sorry for the noise.

Generated at Thu Feb 08 07:31:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.