Skip to content

Commit a38073d

Browse files
author
Ajo Robert
committed
Bug#34758905 Range analysis for IN list has O(n^2) runtime complexity
During optimization, range SEL_TREE creation uses different logic based on the LHS of the IN predicate. For a field item, each RHS value is added to an OR tree to create the necessary expression. In the case of a row item comparison, a DNF expression is needed. A DNF expression is created by adding an AND tree with column values to an OR tree for each set of RHS values. Instead of adding each new AND tree to the OR tree, the OR tree is added to the AND tree causing exponential time during the tree merge. Solution: Change the tree joining the order. Instead of adding OR tree to the AND tree, add AND tree to the OR tree. Change-Id: I93503f3a8e3d6fd181aa40364d24f2868f294168
1 parent cfd5f34 commit a38073d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sql/opt_range.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6380,7 +6380,7 @@ static SEL_TREE *get_func_mm_tree_from_in_predicate(RANGE_OPT_PARAM *param,
63806380
if (and_tree == NULL)
63816381
return NULL;
63826382
}
6383-
or_tree= tree_or(param, and_tree, or_tree);
6383+
or_tree= tree_or(param, or_tree, and_tree);
63846384
}
63856385
return or_tree;
63866386
}

0 commit comments

Comments
 (0)