Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch multi queries #236

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Batch multi queries #236

wants to merge 1 commit into from

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.

To avoid massive multi read or write queries, we'll upsert and
select in batches of 1000 keys.
private
def write_entries(count = 20)
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

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