mayBenefitFromIndexForIn returns true if at least one tuple element is in pk [#CLICKHOUSE-3680]

This commit is contained in:
Nikolai Kochetov 2018-04-03 21:37:35 +03:00
parent ad137994f9
commit a687c41a8c

View File

@ -2195,12 +2195,11 @@ bool MergeTreeData::mayBenefitFromIndexForIn(const ASTPtr & left_in_operand) con
if (left_in_operand_tuple && left_in_operand_tuple->name == "tuple") if (left_in_operand_tuple && left_in_operand_tuple->name == "tuple")
{ {
for (const auto & item : left_in_operand_tuple->arguments->children) for (const auto & item : left_in_operand_tuple->arguments->children)
if (!isPrimaryKeyColumnPossiblyWrappedInFunctions(item)) if (isPrimaryKeyColumnPossiblyWrappedInFunctions(item))
/// The tuple itself may be part of the primary key, so check that as a last resort. return true;
return isPrimaryKeyColumnPossiblyWrappedInFunctions(left_in_operand);
/// tuple() is invalid but can still be found here since this method may be called before the arguments are validated. /// The tuple itself may be part of the primary key, so check that as a last resort.
return !left_in_operand_tuple->arguments->children.empty(); return isPrimaryKeyColumnPossiblyWrappedInFunctions(left_in_operand);
} }
else else
{ {