[MDEV-18501] Partition pruning doesn't work for historical queries Created: 2019-02-07  Updated: 2020-04-15  Resolved: 2019-09-01

Status: Closed
Project: MariaDB Server
Component/s: Partitioning, Versioned Tables
Affects Version/s: 10.3, 10.4
Fix Version/s: 10.3.18, 10.4.8

Type: Bug Priority: Major
Reporter: Aleksey Midenkov Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
causes MDEV-21195 INSERT chooses wrong partition for RA... Closed
Relates
relates to MDEV-17613 MIN/MAX Optimization (Select tables o... Stalled
relates to MDEV-22247 History partition overflow leads to w... Closed

 Description   

Reproduce

set timestamp= unix_timestamp('2001-01-01 00:00:00');
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day
    (partition p0 history, partition p1 history, partition p2 history, partition pn current);
insert t1 values (0); delete from t1;
set timestamp= unix_timestamp('2001-01-02 00:00:00');
insert t1 values (1); delete from t1;
set timestamp= unix_timestamp('2001-01-03 00:00:00');
insert t1 values (2); delete from t1;
select *, row_start, row_end from t1 partition (pn);
select *, row_start, row_end from t1 partition (p0);
select *, row_start, row_end from t1 partition (p1);
select *, row_start, row_end from t1 partition (p2);
 
explain partitions select * from t1 for system_time as of '2001-01-02 00:00:00';

Result

+------+-------------+-------+-------------+------+---------------+------+---------+------+------+-------------+
| id   | select_type | table | partitions  | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+------+-------------+-------+-------------+------+---------------+------+---------+------+------+-------------+
|    1 | SIMPLE      | t1    | p0,p1,p2,pn | ALL  | NULL          | NULL | NULL    | NULL |    4 | Using where |
+------+-------------+-------+-------------+------+---------------+------+---------+------+------+-------------+

Expected

Since row_end >= '2001-01-02 00:00:00' partition p0 must be pruned from query.



 Comments   
Comment by Aleksey Midenkov [ 2019-08-27 ]

Analysis

Comment by Oleksandr Byelkin [ 2019-08-29 ]

OK to push.

Generated at Thu Feb 08 08:44:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.