Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ SQL

`ORDER BY` alone uses a blocking `Sort` (memory O(n)). `ORDER BY` + `LIMIT` becomes `TopK`: still one pass over the child, but the heap only keeps k rows. `LIMIT` alone just stops after n rows.

The planner splits `WHERE` on `AND` and attaches each piece to the lowest input whose columns can resolve it. That is the same idea as predicate pushdown in Spark; there is no cost-based optimizer.
The planner splits `WHERE` on `AND` and attaches each piece to the lowest input whose columns can resolve it. That is the same idea as predicate pushdown in Spark. Join order is the one cost-based decision: the filtered row counts from pushdown feed the Selinger search described above.

## Example

Expand Down
4 changes: 2 additions & 2 deletions tinyquery/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ def __eq__(self, other: object) -> bool:
class Sort(Operator):
"""Blocking sort: read the child fully, then emit in order.

LIMIT after this still pays for the full sort. A real engine would keep a heap
of size LIMIT; we do not.
Memory is O(n). The planner only uses this for ORDER BY without LIMIT; with a
LIMIT it picks TopK, which keeps a heap of k rows instead.
"""

def __init__(self, child: Operator, keys: list[Expr], descending: list[bool]) -> None:
Expand Down
Loading