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

fix: limit row cnt #138

Merged
merged 1 commit into from
Mar 26, 2024
Merged

fix: limit row cnt #138

merged 1 commit into from
Mar 26, 2024

Conversation

Gun9niR
Copy link
Contributor

@Gun9niR Gun9niR commented Mar 26, 2024

Change the LIMIT output cardinality to min(child, fetch). In the below, I hard-coded PhysicalScan's cardinality to 10, because cli does not support stats yet.

❯     create table t1(v1 int);

0 rows in set. Query took 0.011 seconds.

Execution took 0.000 secs, Planning took 0.000 secs
❯     insert into t1 values (0), (1), (2), (3);

❯ explain verbose select * from t1 limit 2;
+--------------------------------------------------+-------------------------------------------------------------------------------------------------+
| plan_type                                        | plan                                                                                            |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------+
| logical_plan after datafusion                    | Limit: skip=0, fetch=2                                                                          |
|                                                  |   Projection: t1.v1                                                                             |
|                                                  |     TableScan: t1                                                                               |
| logical_plan after optd                          | LogicalLimit { skip: 0, fetch: 2 }                                                              |
|                                                  | └── LogicalProjection { exprs: [ #0 ] }                                                         |
|                                                  |     └── LogicalScan { table: t1 }                                                               |
| physical_plan after optd                         | PhysicalLimit { skip: 0, fetch: 2, cost: weighted=3.12,row_cnt=1.00,compute=2.12,io=1.00 }      |
|                                                  | └── PhysicalProjection { exprs: [ #0 ], cost: weighted=1.06,row_cnt=1.00,compute=0.06,io=1.00 } |
|                                                  |     └── PhysicalScan { table: t1, cost: weighted=1.00,row_cnt=1.00,compute=0.00,io=1.00 }       |
| physical_plan after optd-join-order              | t1                                                                                              |
| physical_plan after optd-all-join-orders         | SAME TEXT AS ABOVE                                                                              |
| physical_plan after optd-all-logical-join-orders | SAME TEXT AS ABOVE                                                                              |
| physical_plan                                    | GlobalLimitExec: skip=0, fetch=2                                                                |
|                                                  |   ProjectionExec: expr=[<expr>@0 as col0]                                                       |
|                                                  |     MemoryExec: partitions=1, partition_sizes=[1]                                               |
|                                                  |                                                                                                 |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------+

Copy link
Member

@wangpatrick57 wangpatrick57 left a comment

Choose a reason for hiding this comment

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

LGTM

@Gun9niR Gun9niR merged commit 91a7879 into main Mar 26, 2024
1 check passed
@Gun9niR Gun9niR deleted the zhidong/fix-limit-cost branch March 26, 2024 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants