Why does the order of the loops affect performance when iterating over a 2D array?

As others have said, the issue is the store to the memory location in the array: x[i][j]. Here’s a bit of insight why: You have a 2-dimensional array, but memory in the computer is inherently 1-dimensional. So while you imagine your array like this: 0,0 | 0,1 | 0,2 | 0,3 —-+—–+—–+—- 1,0 | 1,1 … Read more

MYSQL OR vs IN performance

The accepted answer doesn’t explain the reason. Below are quoted from High Performance MySQL, 3rd Edition. In many database servers, IN() is just a synonym for multiple OR clauses, because the two are logically equivalent. Not so in MySQL, which sorts the values in the IN() list and uses a fast binary search to see … Read more

Google app script timeout ~ 5 minutes?

One thing you could do (this of course depends on what you are trying to accomplish) is: Store the necessary information (i.e. like a loop counter) in a spreadsheet or another permanent store(i.e. ScriptProperties). Have your script terminate every five minutes or so. Set up a time driven trigger to run the script every five … Read more