HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/gems/default/doc/activerecord-6.1.4.1/ri/ActiveRecord/Batches/find_in_batches-i.ri
U:RDoc::AnyMethod[iI"find_in_batches:ETI"*ActiveRecord::Batches#find_in_batches;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph;	[I"HYields each batch of records that was found by the find options as ;TI"an array.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim;	[	I"9Person.where("age > 21").find_in_batches do |group|
;TI"B  sleep(50) # Make sure it doesn't get too crowded in there!
;TI"7  group.each { |person| person.party_all_night! }
;TI"	end
;T:@format0o;
;	[I"UIf you do not provide a block to #find_in_batches, it will return an Enumerator ;TI"%for chaining with other methods:;T@o;;	[	I"9Person.find_in_batches.with_index do |group, batch|
;TI")  puts "Processing group ##{batch}"
;TI".  group.each(&:recover_from_last_night!)
;TI"	end
;T;
0o;
;	[I"BTo be yielded each record one by one, use #find_each instead.;T@S:RDoc::Markup::Heading:
leveli	:	textI"Options;To:RDoc::Markup::List:
@type:BULLET:@items[
o:RDoc::Markup::ListItem:@label0;	[o;
;	[I"N<tt>:batch_size</tt> - Specifies the size of the batch. Defaults to 1000.;To;;0;	[o;
;	[I"]<tt>:start</tt> - Specifies the primary key value to start from, inclusive of the value.;To;;0;	[o;
;	[I"Z<tt>:finish</tt> - Specifies the primary key value to end at, inclusive of the value.;To;;0;	[o;
;	[I"o<tt>:error_on_ignore</tt> - Overrides the application config to specify if an error should be raised when ;TI")an order is present in the relation.;To;;0;	[o;
;	[I"`<tt>:order</tt> - Specifies the primary key order (can be :asc or :desc). Defaults to :asc.;T@o;
;	[I"NLimits are honored, and if present there is no requirement for the batch ;TI"Dsize: it can be less than, equal to, or greater than the limit.;T@o;
;	[
I"HThe options +start+ and +finish+ are especially useful if you want ;TI"Kmultiple workers dealing with the same processing queue. You can make ;TI"Hworker 1 handle all the records between id 1 and 9999 and worker 2 ;TI"Hhandle from 10000 and beyond by setting the +:start+ and +:finish+ ;TI"option on each worker.;T@o;;	[	I",# Let's process from record 10_000 on.
;TI"6Person.find_in_batches(start: 10_000) do |group|
;TI"7  group.each { |person| person.party_all_night! }
;TI"	end
;T;
0o;
;	[	I"[NOTE: Order can be ascending (:asc) or descending (:desc). It is automatically set to ;TI".ascending on the primary key ("id ASC"). ;TI"IThis also means that this method only works when the primary key is ;TI"+orderable (e.g. an integer or string).;T@o;
;	[I"LNOTE: By its nature, batch processing is subject to race conditions if ;TI"0other processes are modifying the database.;T:
@fileI"*lib/active_record/relation/batches.rb;T:0@omit_headings_from_table_of_contents_below00I"	to_a;T[I"S(start: nil, finish: nil, batch_size: 1000, error_on_ignore: nil, order: :asc);T@\FI"Batches;TcRDoc::NormalModule00