Skip to content

Commit

Permalink
perf: fix join performance by avoiding Projection construction
Browse files Browse the repository at this point in the history
This avoids the large number of repeated traversals on construction.
  • Loading branch information
cpcloud authored and kszucs committed Sep 19, 2022
1 parent 894eaf8 commit ed532bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions ibis/expr/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import ibis.expr.types as ir
from ibis import util
from ibis.common.exceptions import IbisTypeError, IntegrityError
from ibis.expr.operations.relations import Projection
from ibis.expr.rules import Shape
from ibis.expr.window import window

Expand Down Expand Up @@ -612,7 +611,7 @@ def _find_projections(node):
if isinstance(node, ops.Selection):
# remove predicates and sort_keys, so that child tables are considered
# equivalent even if their predicates and sort_keys are not
return lin.proceed, Projection(node.table, node.selections)
return lin.proceed, node._projection
elif isinstance(node, ops.SelfReference):
return lin.proceed, node
elif isinstance(node, ops.Join):
Expand Down
4 changes: 4 additions & 0 deletions ibis/expr/operations/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ def sort_by(self, sort_exprs):

return Selection(self, [], sort_keys=keys)

@immutable_property
def _projection(self):
return Projection(self.table, self.selections)


@public
class Aggregation(TableNode):
Expand Down

0 comments on commit ed532bf

Please sign in to comment.