cancel
Showing results for 
Search instead for 
Did you mean: 

Foreach vs Where in Cloud Application Studio

kumar_rituraj
Active Participant
0 Kudos

Dear Experts,

I would like to know which keyword is faster, foreach or where.

From blog https://blogs.sap.com/2015/08/27/sap-cloud-application-studio-performance-best-practices/ I understood where translates into for loop and therefore it is slower than foreach but from C# tutorial I understand for has better performance over foerach. This bring back again same question which one is faster.

Please let me know.

Regards

Rituraj

Accepted Solutions (1)

Accepted Solutions (1)

VVancalbergh
Contributor
0 Kudos

The Q&A in the blog post is a bit misleading in its phrasing: Yes, Where translates into a foreach + if statements. But it has the possibility of being optimized by the compiler later on. If you use foreach + ifs yourself it'll have the exact same performance without the chance of future optimization.

This is similar to C#. Worst case you get the same performance as doing the loop yourself, but chances are it'll get optimized. Chances are simply greater in C# because there are so many libraries already for it (like the Entity Framework).

WTB Library Integration and more direct Database Access for ABSL !

Answers (0)