I know that the discussion of whether while loops and for loops are faster is very popular, but I haven't seen any with this particular question.
I am currently developing stored procedures in Snowflake. These SPs use Javascript to handle the logic.
I have the need to create some loops to run several (potentially thousands) SQL queries so I was wondering which could be the best approach for performance and safety.
I am worried about using while loops because it seems to me that it would be slower if the condition to evaluate was dependent on the result of a transaction, because the JS thread would need to stop to wait for the Snowflake query to return data in order to evaluate it again, whereas a normal for loop would just increment/decrement the counter and evaluate from inside the JS thread without needing to wait for a new set of results.
Which also leads me to a new questions: If this is true, would it mean that a while loop is safer since the for loop has the chance of becoming losing sync (in regards to the results obtained from Snowflake)?
I am not saying that this is the way things happen, rather, I'm just trying to confirm if this is actually how it goes or if I'm wrong. As I said I could not find many related resources to this.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…