Optimize previous run query to only check last 1000 finished jobs