[MDEV-12404] index condition pushdown on partitioned tables Created: 2017-03-30  Updated: 2024-02-02

Status: In Review
Project: MariaDB Server
Component/s: Partitioning
Fix Version/s: 11.5

Type: Task Priority: Major
Reporter: Markus Dorfer Assignee: Sergei Petrunia
Resolution: Unresolved Votes: 1
Labels: optimizer-easy

Issue Links:
Duplicate
is duplicated by MDEV-32227 Partition Table do not using (Using i... Closed
Relates
relates to MDEV-21625 Index condition pushdown is not used ... Open

 Description   

hi,

index condition pushdown was added with in mysql 5.7.3 for partitioned tables with commit https://github.com/mysql/mysql-server/commit/67d2e4ef917e49b0c14cee50e47a498f3f3d95d1

by what i found out by now this feature is not yet available in mariadb and would be a great addition.

thx

markus



 Comments   
Comment by Sergei Petrunia [ 2023-10-20 ]

A simple testcase:

create table t1 ( 
  pk int primary key,
  a int, 
  b int,
  c int,
  filler varchar(100),
  key(a,b,c)
) partition by hash(pk) partitions 4;
 
insert into t1 select seq, seq, seq, seq, 'hello' from seq_1_to_10000;
explain format=json select * from t1 where a < 10 and (b+1>3);

shows

{
  "query_block": {
    "select_id": 1,
    "cost": 0.02196592,
    "nested_loop": [
      {
        "table": {
          "table_name": "t1",
          "partitions": ["p0", "p1", "p2", "p3"],
          "access_type": "range",
          "possible_keys": ["a"],
          "key": "a",
          "key_length": "5",
          "used_key_parts": ["a"],
          "loops": 1,
          "rows": 9,
          "cost": 0.02196592,
          "filtered": 100,
          "attached_condition": "t1.a < 10 and t1.b + 1 > 3"
        }
      }
    ]
  }
}

Note that the conditions are in attached_condition.

For comparison, let's run the same on a non-partitioned table:

create table t2 ( 
  pk int primary key,
  a int, 
  b int,
  c int,
  filler varchar(100),
  key(a,b,c)
);
insert into t2 select seq, seq, seq, seq, 'hello' from seq_1_to_10000;
explain format=json select * from t2 where a < 10 and (b+1>3);

shows

{
  "query_block": {
    "select_id": 1,
    "cost": 0.0146548,
    "nested_loop": [
      {
        "table": {
          "table_name": "t2",
          "access_type": "range",
          "possible_keys": ["a"],
          "key": "a",
          "key_length": "5",
          "used_key_parts": ["a"],
          "loops": 1,
          "rows": 9,
          "cost": 0.0146548,
          "filtered": 100,
          "index_condition": "t2.a < 10 and t2.b + 1 > 3"
        }
      }
    ]
  }
}

Now, the conditions are in the index_condition.

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