Skip to content

[9.x] Remove duplicate queries to find batch#41121

Merged
taylorotwell merged 1 commit intolaravel:9.xfrom
sebdesign:find-batch
Feb 21, 2022
Merged

[9.x] Remove duplicate queries to find batch#41121
taylorotwell merged 1 commit intolaravel:9.xfrom
sebdesign:find-batch

Conversation

@sebdesign
Copy link
Contributor

Everytime the Batchable::batch() method is called, a database query is performed using the DatabaseBatchRepository.

So when we are recording successful/failed jobs, first we fetch the batch to check if it's null, and then we fetch it again to record the job.

Since it's rendundant to fetch the batch two times from the database, this PR fetches the batch once, and if it exists, it will record the job.

@GrahamCampbell GrahamCampbell changed the title Remove duplicate queries to find batch [9.x] Remove duplicate queries to find batch Feb 19, 2022
@taylorotwell taylorotwell merged commit 502a505 into laravel:9.x Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants