improve query perf for acquiring merge jobs.