TL;DR - How to write efficient code when using loops Bring as much code outside the loop as possible, especially lines that are computationally expensive (such as querying the database) because loops are O(n) "big-oh of n" and need to be run once for every input item, whereas code outside a loop is O(c) "constant time" and take the same amount of ...Read MoreThe post How to Write Efficient Code (by example) Part 1: Databases and Loops appeared first on Legend Web Solutions.