I have a function in my code that connects to postgress db using spring jpa. It fetches the execution count and workflow id of all the workflows in a table using the following query.
select execution_count, workflow_id from <table> where version =<> and run_id =<>
The version and run_id here are not the keys.(so I cannot using findAllById) I'am re-writing this function to a do a bulk fetch. I can use a for loop following way
for(...) { int count = runDetailsDao.getExecutionCount(version,run_id)
However each time the loop iterates a new transaction is created, which doesn't seem an efficient way if the loop iterates too many times (say 200).how can I reduce the number of transactions. What would be an efficient way in this case?