-
Notifications
You must be signed in to change notification settings - Fork 4.1k
opt: transform some of the expressions into equivalent CASE expressions #77799
Copy link
Copy link
Open
Labels
C-cleanupTech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.E-quick-winLikely to be a quick win for someone experienced.Likely to be a quick win for someone experienced.E-starterMight be suitable for a starter project for new employees or team members.Might be suitable for a starter project for new employees or team members.T-sql-queriesSQL Queries TeamSQL Queries Team
Description
In the vectorized execution engine we use the CASE operator to support several expressions. We do so during the vectorized planning, but it seems more appropriate to do the transformation during the normalization stage of the optimization.
I believe that the execution in the row-by-row engine will not suffer performance-wise, so we'll be able to remove the implementations of Eval methods for the corresponding expressions.
In particular, the following constructs are implemented in the vectorized planning:
WHERE a OR b- into
WHERE CASE WHEN a THEN true WHEN b THEN true ELSE false END
- into
COALESCE(a, b, ...)- into
CASE WHEN a IS DISTINCT FROM NULL THEN a WHEN b IS DISTINCT FROM NULL THEN b ... END
-IF(a, b, c)
- intoCASE WHEN a THEN b ELSE c END
-NULLIF(a, b)
- intoCASE WHEN a = b THEN NULL ELSE a END.
- into
Jira issue: CRDB-13769
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-cleanupTech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.E-quick-winLikely to be a quick win for someone experienced.Likely to be a quick win for someone experienced.E-starterMight be suitable for a starter project for new employees or team members.Might be suitable for a starter project for new employees or team members.T-sql-queriesSQL Queries TeamSQL Queries Team
Type
Projects
Status
Backlog