cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

sql/sem/normalize: remove ConstantEvalVisitor

Open mgartner opened this issue 1 year ago • 4 comments

sql/rowexec: handle re-parsed lookup expressions in join reader

Previously, the join reader relied on the normalize.ConstantEvalVisitor used in execinfrapb.DeserializeExpr to convert tuples in serialized lookup expressions from *tree.Tuples to *tree.DTuples. This commit break this reliance.

Release note: None

sql/sem/normalize: remove ConstantEvalVisitor

The ConstantEvalVisitor was introduced in #30216 as a work around for a poorly performing type of query. It turned an ARRAY AST node with all constant children into a DArray. The optimizer now performs this optimization in the execbuilder phase. To be sure this is no longer needed, I ran several queries similar to the original motivating examples and saw no measurable performance difference.

Epic: None

Release note: None

mgartner avatar Feb 22 '24 23:02 mgartner

This change is Reviewable

cockroach-teamcity avatar Feb 22 '24 23:02 cockroach-teamcity

A classic 5 year "temporary fix" finally addressed. cc @RaduBerinde.

mgartner avatar Feb 22 '24 23:02 mgartner

@DrewKimball I added a new commit to address one assumption in the join reader that broke because of this. PTAL.

mgartner avatar Feb 23 '24 18:02 mgartner

Hmm I wonder if this could cause a regression in the row-based engine in the case that a filter like i IN (1 , 3, …) is pushed to another node.

mgartner avatar Feb 24 '24 00:02 mgartner

I re-tested this and it did cause a significant regression when evaluating a distributed filter like in SELECT * FROM t WHERE a IN (1, 2, 3, 4, ..., 9999);. Closing.

mgartner avatar Mar 16 '24 18:03 mgartner