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

Merged
merged 2 commits into from
Feb 4, 2025
Merged

Batch multi queries #236

merged 2 commits into from
Feb 4, 2025

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.

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

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