Skip to content

Commit 427fe31

Browse files
committed
Select primary keys instead of full records
It can help performance by avoiding table lookups and reducing network usage.
1 parent 15bac4a commit 427fe31

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/safe-pg-migrations/helpers/batch_over.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def each_batch
1919
def next_batch
2020
return if endless?
2121

22-
first = next_scope.take
22+
first = next_scope.select(primary_key).take
2323

2424
return unless first
2525

26-
last = next_scope.offset(@of).take
26+
last = next_scope.select(primary_key).offset(@of).take
2727

2828
first_key = first[primary_key]
2929
last_key = last.nil? ? nil : last[primary_key]

0 commit comments

Comments
 (0)