You are right! Progress query should be written as the SQL query. Started with item_price, join item, join agreement. When this was done, the time went down from 37 seconds to 3 seconds.
In this code, after the loop was changed to a "3-secondsloop", there was no difference when switching from...