DEV Community

[Comment from a deleted post]
 
geraldew profile image
geraldew

You may find that this depends very much on the platform. I feel I can attest from experience that on Teradata the optimisation definitely favours the CASE expression as long as it doesn't get so overly complex as to blow the memory of the distribution element (Teradata has its own internal terminology which I won't quote).

In that vein, while I wouldn't defend it, I've certainly seen CASE expressions with a hundred WHEN clauses implementing the quirky logic combinations that come from bureaucratic classifications. There are times when any attempt to abstract that to a function or a table join would be even more unwieldy and introduce more overheads than the CASE expression.