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

Push down limit on IndexLookUp operator can be improved #35952

Closed
Reminiscent opened this issue Jul 5, 2022 · 1 comment · Fixed by #42818
Closed

Push down limit on IndexLookUp operator can be improved #35952

Reminiscent opened this issue Jul 5, 2022 · 1 comment · Fixed by #42818
Labels
affects-7.1 This bug affects the 7.1.x(LTS) versions. sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.

Comments

@Reminiscent
Copy link
Contributor

Reminiscent commented Jul 5, 2022

Enhancement

Related to #10668 and #25063.

Now, when we push down limit to indexLookUp, it has some restriction. We should unrestricted it by keeping the Limit or Projection operator.

Before the change(now):

mysql> create table t3(a int, b int, key(a));
Query OK, 0 rows affected (0.03 sec)

mysql> explain select * from t3 order by a limit 10000, 100;
+------------------------------------+----------+-----------+----------------------+--------------------------------+
| id                                 | estRows  | task      | access object        | operator info                  |
+------------------------------------+----------+-----------+----------------------+--------------------------------+
| Limit_12                           | 100.00   | root      |                      | offset:10000, count:100        |
| └─Projection_23                    | 10000.00 | root      |                      | test.t3.a, test.t3.b           |
|   └─IndexLookUp_22                 | 10000.00 | root      |                      |                                |
|     ├─Limit_21(Build)              | 10000.00 | cop[tikv] |                      | offset:0, count:10100          |
|     │ └─IndexFullScan_19           | 10000.00 | cop[tikv] | table:t3, index:a(a) | keep order:true, stats:pseudo  |
|     └─TableRowIDScan_20(Probe)     | 10000.00 | cop[tikv] | table:t3             | keep order:false, stats:pseudo |
+------------------------------------+----------+-----------+----------------------+--------------------------------+
6 rows in set (0.00 sec)

After the change(future):

mysql> explain select * from t3 order by a limit 10000, 100;
+------------------------------------+----------+-----------+----------------------+-----------------------------------------+
| id                                 | estRows  | task      | access object        | operator info                           |
+------------------------------------+----------+-----------+----------------------+-----------------------------------------+
| Limit_12                           | 100.00   | root      |                      | offset:10000, count:100                 |
| └─Projection_23                    | 100.00   | root      |                      | test.t3.a, test.t3.b                    |
|   └─IndexLookUp_22                 | 100.00   | root      |                      | limit embedded(offset:10000, count:100) |
|     ├─Limit_21(Build)              | 10000.00 | cop[tikv] |                      | offset:0, count:10100                   |
|     │ └─IndexFullScan_19           | 10000.00 | cop[tikv] | table:t3, index:a(a) | keep order:true, stats:pseudo           |
|     └─TableRowIDScan_20(Probe)     | 100.00   | cop[tikv] | table:t3             | keep order:false, stats:pseudo          |
+------------------------------------+----------+-----------+----------------------+-----------------------------------------+
6 rows in set (0.01 sec)
@Reminiscent Reminiscent added type/enhancement The issue or PR belongs to an enhancement. sig/planner SIG: Planner labels Jul 5, 2022
@winoros
Copy link
Member

winoros commented Jul 7, 2022

The example here is wrong?
Misread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.1 This bug affects the 7.1.x(LTS) versions. sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants