Repository navigation
Conversation
db.Query.Each called Chunk(1, ...), issuing one LIMIT 1 OFFSET n query per row plus a final empty one (N+1 queries for N rows, each OFFSET scan getting slower). Fetch rows in chunks of 1000 instead, as Laravel does, while still invoking the callback once per row.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1582 +/- ##
==========================================
+ Coverage 72.91% 73.06% +0.15%
==========================================
Files 412 412
Lines 26893 26893
==========================================
+ Hits 19608 19649 +41
+ Misses 7283 7242 -41
Partials 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
JGamboa
marked this pull request as ready for review
October 18, 2026 23:47
Contributor
Author
|
Review Ready |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📑 Description
Closes goravel/goravel#1018
db.Query.EachusedChunk(1): oneLIMIT 1 OFFSET nquery per row plus a final empty one. Now it fetches rows in chunks of 1000, the same default as Laravel'seach(), and keeps the public API and the per-row callback. With fewer than 1000 rows it runs a single query, and a callback error still stops the iteration right away.✅ Checks
TestDBTestSuite/TestEachintests/db_test.gochecks the order, that a single query appears in the query log, and that the iteration stops on a callback error. It fails on master (4 queries for 3 rows) and passes here on all four drivers. There were noEachtests before.