This repository was archived by the owner on Jan 7, 2025. It is now read-only.
Commit 91a7879
authored
fix: limit row cnt (#138)
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] |
| | |
+--------------------------------------------------+-------------------------------------------------------------------------------------------------+
```1 parent 41192d4 commit 91a7879
1 file changed
+36
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
392 | 394 | | |
393 | 395 | | |
394 | 396 | | |
395 | | - | |
396 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
397 | 430 | | |
398 | 431 | | |
399 | 432 | | |
| |||
0 commit comments