-
Notifications
You must be signed in to change notification settings - Fork 368
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
Allow worker strategies to receive import options #321
Conversation
Could you provide usage examples please? |
Here in the issue for justification? Or do you want examples in the worker comments, or README? |
Well, I'm just curious :) Simply leave it here |
I use it like his to allow me do my large imports in the background instead of in a console session. User.where(status: :active).find_in_batches do |users|
Chewy::Strategy::Sidekiq::Worker.perform_async("UsersIndex::User", users.map(&:id), suffix: '20160125')
end Once all my workers are done I just switch the alias to point to the new suffix. Exactly like what the builtin import in rake does, except in the background. |
Hm, interesting, got it. Is it much faster? |
Allow worker strategies to receive import options
Pretty much as fast as I want to make it since I can control how many workers are available to process the jobs.I have an index that previously took around 17 hours to reindex that I have now reindexed in as fast as 15-20 minutes. Also, I don't have to worry about running in screen in case the ssh session gets interrupted and have to try and figure out where to restart the import. |
Awesome, thanks! |
Btw, 15-20 minutes of queueing? Or complete indexing? |
complete indexing. I just throw a few dozen workers at it. On Thu, Jan 28, 2016 at 9:08 AM, Arkadiy Zabazhanov <
|
Perfect, thanks again |
@dnd @pyromaniac |
Well, there are two possible causes: AR objects instantiation and document composing. For the first case it is possible to use plain SQL query or so to get data in hashes. It is probably possible since chewy supports plain objects. Also AR 4 has a bug which makes As for document composing - Witchcraft™ will help to speed it up. In synthetic tests it gave me up to 80% speed-up. With heavy heavy associations preloading in real app it gives 20% speed-up, so it depends and you have to try. |
@pyromaniac |
This pull allows the Sidekiq, Resque, and ActiveJob strategy workers to be called with an options hash to pass to
#import!
. It makes it easy to completely rebuild an index with a different suffix in the background.