Skip to content

Commit

Permalink
optimized AND ruins performance
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkramaric committed Mar 7, 2016
1 parent 2239835 commit 7ad1439
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
23 changes: 1 addition & 22 deletions daffodil/hstore_predicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,7 @@ def mk_all(self, children):
if children == ['']:
return "true"

sql_expr = " AND ".join("({})".format(child_exp) for child_exp in children if child_exp)

if any(breaks_optimizer(child_exp) for child_exp in children):
return sql_expr

keys = {child_exp.daff_key for child_exp in children}
if len(keys) <= 1:
return sql_expr

optimization_expr = "{field} ?& {keys}".format(
field=self.field,
keys=make_sql_array(*keys)
)

sql_expr = " AND ".join("({})".format(child_exp)
for child_exp in children
if child_exp.daff_test != "?="
)
if sql_expr:
return "{0} AND {1}".format(optimization_expr, sql_expr)
else:
return optimization_expr
return " AND ".join("({})".format(child_exp) for child_exp in children if child_exp)

def mk_not_any(self, children):
return " NOT ({0})".format(self.mk_any(children))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='daffodil',
version='0.3.9.1',
version='0.3.9.2',
author='James Robert',
description='A Super-simple DSL for filtering datasets',
license='MIT',
Expand Down

0 comments on commit 7ad1439

Please sign in to comment.