Skip to content

Conversation

djmb
Copy link
Collaborator

@djmb djmb commented Nov 6, 2024

To avoid massive multi read or write queries, we'll upsert and select in batches of 1000 keys.

Entry.write_multi(count.times.map { |i| { key: "key#{i}", value: "value#{i}" } })
end

def with_multi_batch_size(value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using stub_const? This logic is almost the same as that method.
https://api.rubyonrails.org/classes/ActiveSupport/Testing/ConstantStubbing.html#method-i-stub_const

djmb added 2 commits February 4, 2025 16:18
To avoid massive multi read or write queries, we'll upsert and
select in batches of 1000 keys.
@djmb djmb force-pushed the batch-multi-queries branch from 730371a to eec30e8 Compare February 4, 2025 16:18
@djmb djmb merged commit e5729b4 into main Feb 4, 2025
22 checks passed
@djmb djmb deleted the batch-multi-queries branch February 4, 2025 16:53
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