Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: support BatchPointGet for partition table #21857

Closed
wants to merge 3 commits into from

Conversation

xiaodong-ji
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #21847

Problem Summary: Partition table didn't support BatchPointGet.

What is changed and how it works?

What's Changed:

How it Works:

Check List

Tests

  • Manual test
create table t1 (c int primary key)
PARTITION BY RANGE (c) (
    PARTITION p0 VALUES LESS THAN (6),
    PARTITION p1 VALUES LESS THAN (11),
    PARTITION p2 VALUES LESS THAN (16),
    PARTITION p3 VALUES LESS THAN (21)
);

mysql> explain select * from t1 where c in (1,10);
+--------------------------+---------+------+---------------+---------------------------------------------+
| id                       | estRows | task | access object | operator info                               |
+--------------------------+---------+------+---------------+---------------------------------------------+
| PartitionUnion_9         | 4.00    | root |               |                                             |
| ├─Batch_Point_Get_10     | 2.00    | root | table:t1      | handle:[1 10], keep order:false, desc:false |
| └─Batch_Point_Get_11     | 2.00    | root | table:t1      | handle:[1 10], keep order:false, desc:false |
+--------------------------+---------+------+---------------+---------------------------------------------+
3 rows in set (0.01 sec)

Release note

  • support BatchPointGet for partition table

@xiaodong-ji xiaodong-ji requested a review from a team as a code owner December 17, 2020 08:05
@xiaodong-ji xiaodong-ji requested review from winoros and removed request for a team December 17, 2020 08:05
@@ -691,7 +691,7 @@ func (ds *DataSource) findBestTask(prop *property.PhysicalProperty, planCounter
p: dual,
}, cntPlan, nil
}
canConvertPointGet := (!ds.isPartition && len(path.Ranges) > 0) || (ds.isPartition && len(path.Ranges) == 1)
canConvertPointGet := (!ds.isPartition || ds.isPartition) && len(path.Ranges) > 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(!ds.isPartition || ds.isPartition) always true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -691,7 +691,7 @@ func (ds *DataSource) findBestTask(prop *property.PhysicalProperty, planCounter
p: dual,
}, cntPlan, nil
}
canConvertPointGet := (!ds.isPartition && len(path.Ranges) > 0) || (ds.isPartition && len(path.Ranges) == 1)
canConvertPointGet := len(path.Ranges) > 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lysu For partition table, multi-range can also triger Get/BatchGet operation, right?

Copy link
Contributor

@lysu lysu Dec 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess maybe some reason let #14775 (comment) only support single range? @lzmhhh123 😕

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot the reason. Maybe the previous point get can't handle the partition table.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh...current point get can handle the partition

@ichn-hu ichn-hu mentioned this pull request Dec 18, 2020
@Yisaer
Copy link
Contributor

Yisaer commented Dec 21, 2020

I think only modifying planner is not enough as I got the following test result after I applied the changing:

mysql> create table t1 (c int primary key)
    -> PARTITION BY RANGE (c) (
    ->     PARTITION p0 VALUES LESS THAN (6),
    ->     PARTITION p1 VALUES LESS THAN (11),
    ->     PARTITION p2 VALUES LESS THAN (16),
    ->     PARTITION p3 VALUES LESS THAN (21)
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 (c) values (1);
Query OK, 1 row affected (0.00 sec)

mysql> insert into t1 (c) values (0);
Query OK, 1 row affected (0.00 sec)

mysql> insert into t1 (c) values (10);
Query OK, 1 row affected (0.00 sec)

mysql> explain select * from t1 where c in (1,10);
+--------------------------+---------+------+---------------+---------------------------------------------+
| id                       | estRows | task | access object | operator info                               |
+--------------------------+---------+------+---------------+---------------------------------------------+
| PartitionUnion_9         | 4.00    | root |               |                                             |
| ├─Batch_Point_Get_10     | 2.00    | root | table:t1      | handle:[1 10], keep order:false, desc:false |
| └─Batch_Point_Get_11     | 2.00    | root | table:t1      | handle:[1 10], keep order:false, desc:false |
+--------------------------+---------+------+---------------+---------------------------------------------+
3 rows in set (0.00 sec)

mysql> select * from t1 where c in (1,10);
Empty set (0.00 sec)

The BatchPointGetExecutor.initialize is also needed to be revised. @xiaodong-ji

@ti-chi-bot ti-chi-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 22, 2021
@zz-jason
Copy link
Member

@xiaodong-ji please add some tests to ensure the correctness and performance improvements, we need these tests to check:

  • execution plan changes are correct and as expected
  • query result is correct
  • performance is improved

@ti-srebot
Copy link
Contributor

@xiaodong-ji, please update your pull request.

1 similar comment
@ti-srebot
Copy link
Contributor

@xiaodong-ji, please update your pull request.

@ti-srebot
Copy link
Contributor

@xiaodong-ji PR closed due to no update for a long time. Feel free to reopen it anytime.

@ti-srebot ti-srebot closed this Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Partition table didn't support BatchPointGet
9 participants