We use
SELECT * FROM profile WHERE id IN (1,2,3...)
to get all results in ResultSet. It is essentiallySELECT * FROM profile WHERE id='1' OR id='2' OR id='3'...
We write a loop like:
foreach(int id: ids) {execute(SELECT * FROM profile WHERE id='i')}
As far as I consider, since requests sent DB takes a lot of time, we should reduce the number of times we visit DB, so the first method is better. However, I am not sure whether it's true or not in the industry and is there's a better solution. Please enlight me, thank you :)