Generally speaking, the efficiency of query item by item in the loop is relatively low, which results in connection and concurrent overhead every time.
Are there some scenarios that are suitable to query one by one in a loop, but not suitable for one-time table lookup?
Don’t query in the loop, you can’t see any reason to query in the loop!
If you are an offline task, you do not need to return immediately like a web request, and the amount of data is relatively large, then it is reasonable to cut the query to a certain extent and obtain dozens to hundreds of data at a time (too much data will also cause slow transmission)
Finally, even if you really have to query in the loop, you should use the same connection instead of reestablishing it every time!