title: When does Enumberable's each_slice method begin to make sense for large arrays?
body: <p>I am working with an array that contains about 400,000+ items. I was looking through Enumerables <code>each_slice</code> method on the ruby docs and was wondering to myself if it would make any difference in using it for an array of this size.</p>
  
  <p>According to Rails documentation:</p>
  
  <blockquote>
    <p>1.2 Retrieving Multiple Objects in Batches We often need to iterate over a large set of records, as when we send a newsletter to a large
    set of users, or when we export data.</p>
    
    <p>This may appear straightforward:</p>
  
  <pre><code># This is very inefficient when the users table has thousands of rows. 
  User.all.each do |user|   
    NewsMailer.weekly(user).deliver_now 
  end
  </code></pre>
    
    <p>But
    this approach becomes increasingly impractical as the table size
    increases, since User.all.each instructs Active Record to fetch the
    entire table in a single pass, build a model object per row, and then
    keep the entire array of model objects in memory. Indeed, if we have a
    large number of records, the entire collection may exceed the amount
    of memory available.</p>
    
    <p>Rails provides two methods that address this problem by dividing
    records into memory-friendly batches for processing. The first method,
    find_each, retrieves a batch of records and then yields each record to
    the block individually as a model. The second method, find_in_batches,
    retrieves a batch of records and then yields the entire batch to the
    block as an array of models.</p>
    
    <p>The find_each and find_in_batches methods are intended for use in the
    batch processing of a large number of records that wouldn't fit in
    memory all at once. If you just need to loop over a thousand records
    the regular find methods are the preferred option.</p>
  </blockquote>
  
  <p>Based on this documentation, if I have more than 1,000 array items, would I then start to look into <code>each_slice</code>? Also, how do I know by what number I should split it up to help save memory? Is there a way to figure this out?</p>