Slow loop - gets faster after first run

I am working on building a search function, and I have found the loop to be slow.
I have simplified it to this:

On the browser, the first time this runs through the 40 rows/loops it takes around 40 seconds. All further runs take around 3 seconds.

When run in the Thunkable App, the first run is around the same -40 secs. The further runs, after a 2 second pause, run instantaneously.

Why would the first run take so much longer than the second, and further, runs?

Any thoughts would be appreciated.

Thanks
Tom

I don’t know why the duration would be so different but there’s a more efficient way to find a text string in a data source column by using the find first occurrence of block and the list of values block. I explain it here: Thunkable and returns a corresponding value from my sheet - #2 by tatiang.

Thank you Tatiang.
Can I use the 'find first ocurrence’ to filter the rows of a table where the filtered value has duplicates? I can understand using it where there are only unique values.

No, for that you need to use a loop. Another option is the filterByFormula Airtable API command. But you’d have to be using Airtable for that.

Do you need more than one property (column) from each row? Or is “First_Name” enough? If so, you could simplify by getting the list of values for that single column and then getting a list item for each row # using the loop. Because getting the row object in each iteration of the loop takes time.