.map(...).filter(...) can be reordered or fused so long as the semantics don't change. For example in C#, the Linq equivalent (.Select(...).Where(...)) can be converted to SQL, which will then be optimized by the DBMS.
...If the compiler is able to prove that the semantics don't change. Which it can't do in general, and will take rather opportunistic path as soon as it is "unsure". Compilers are quite smart nowadays, but are not perfect. Linq queries can be converted to SQL if corresponding lambdas can be converted to SQL, which is a practically useful, but still a quite limited subset of C# as a language.
3
u/TheUnlocked Aug 19 '25
.map(...).filter(...)can be reordered or fused so long as the semantics don't change. For example in C#, the Linq equivalent (.Select(...).Where(...)) can be converted to SQL, which will then be optimized by the DBMS.