Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Refactor JOB_PROCESS_WHERE_QUERY to get an optimized query plan #869
This pull request is a simple "refactoring" of the job-pulling query performed by agenda, that yieldsbetter results when there are lots of "expired" jobs in database. As far as I can see, there's no functional impact.
I managed to reproduce this on my computer. I first created 100k "expired Jobs":
Then checked the explain plan of the job pulling request done by agenda:
So 10k index keys were examined :(
One of my colleague played with the query, and found out that with a simple "refactoring" of the request, we got a much better query plan:
Only 100~ keys examined!