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

some adjacent limit is redundant and unnecessary #58746

Open
AilinKid opened this issue Jan 7, 2025 · 0 comments
Open

some adjacent limit is redundant and unnecessary #58746

AilinKid opened this issue Jan 7, 2025 · 0 comments
Labels
planner/cascades issue/enhance/bug related to yams sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.

Comments

@AilinKid
Copy link
Contributor

AilinKid commented Jan 7, 2025

Enhancement

drop table if exists t;
create table t(a int primary key, b int);
insert into t values (1, 11), (4, 44), (2, 22), (3, 33);
set session tidb_executor_concurrency = 4;
set @@session.tidb_hash_join_concurrency = 5;
set @@session.tidb_distsql_scan_concurrency = 15;

mysql> explain select a from (select a from t where b > 2 order by a limit 3 offset 1) as t1 order by a limit 2 offset 1;
+--------------------------------+---------+-----------+---------------+-------------------------------+
| id                             | estRows | task      | access object | operator info                 |
+--------------------------------+---------+-----------+---------------+-------------------------------+
| Limit_18                       | 1.33    | root      |               | offset:1, count:2             |
| └─Limit_44                     | 1.33    | root      |               | offset:1, count:3             |
|   └─TableReader_49             | 1.33    | root      |               | data:Limit_48                 |
|     └─Limit_48                 | 1.33    | cop[tikv] |               | offset:0, count:4             |
|       └─Selection_29           | 1.33    | cop[tikv] |               | gt(test.t.b, 2)               |
|         └─TableFullScan_28     | 4.00    | cop[tikv] | table:t       | keep order:true, stats:pseudo |
+--------------------------------+---------+-----------+---------------+-------------------------------+
6 rows in set (0.00 sec)

expected
Limit_24	2.00	root		offset:2, count:2
  └─TableReader_32	4.00	root		data:Limit_33
    └─Limit_33	4.00	cop[tikv]		offset:0, count:4
      └─Selection_30	4.00	cop[tikv]		gt(planner__cascades__integration.t.b, 2)
        └─TableFullScan_31	4.00	cop[tikv]	table:t	keep order:true, stats:pseudo
@AilinKid AilinKid added type/enhancement The issue or PR belongs to an enhancement. sig/planner SIG: Planner planner/cascades issue/enhance/bug related to yams labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
planner/cascades issue/enhance/bug related to yams sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

1 participant