Bulk update in rails with mongodb
I have a scenario where I need to update some 7k records in mongodb. The
query is
Document.all.each do |d|
d.pages_enabled_count = d.pages.where(:disabled => false).count
d.pages_enabled_to_query_count = d.pages.where(:disabled => false ,
:to_query => true).count
d.pages_enabled_to_rescan_count = d.pages.where(:disabled => false ,
:to_rescan => true).count
d.pages_enabled_to_retag_count = d.pages.where(:disabled => false ,
:to_retag => true).count
d.save
This takes about 5 mins to complete the query. Is there a way to do update
without looping i.e. bulk update in one go?
No comments:
Post a Comment