<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Chunky Iterator: So You Don&#8217;t Have to Load All Your AR Objects at Once</title>
	<atom:link href="http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/</link>
	<description></description>
	<pubDate>Thu, 21 Aug 2008 10:22:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Daniel Higginbotham</title>
		<link>http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/#comment-32</link>
		<dc:creator>Daniel Higginbotham</dc:creator>
		<pubDate>Fri, 23 May 2008 14:15:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.flyingmachinestudios.com/?p=12#comment-32</guid>
		<description>Good catch Frank, thanks!</description>
		<content:encoded><![CDATA[<p>Good catch Frank, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Kuepper</title>
		<link>http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/#comment-29</link>
		<dc:creator>Frank Kuepper</dc:creator>
		<pubDate>Wed, 21 May 2008 05:26:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.flyingmachinestudios.com/?p=12#comment-29</guid>
		<description>Shouldn't the existing_condition in merge_conditions be enclosed in braces? If existing_condition for example was 
&lt;code&gt;"fresh = TRUE OR amount &#62; 5"&lt;/code&gt;
the correct merge should be
&lt;code&gt;"(fresh = TRUE OR amount &#62; 5) AND #{@model_class.table_name}.id &#62; #{id}"&lt;/code&gt;
whereas your code produces
&lt;code&gt;"fresh = TRUE OR amount &#62; 5 AND #{@model_class.table_name}.id &#62; #{id}"&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Shouldn&#8217;t the existing_condition in merge_conditions be enclosed in braces? If existing_condition for example was<br />
<code>"fresh = TRUE OR amount &gt; 5"</code><br />
the correct merge should be<br />
<code>"(fresh = TRUE OR amount &gt; 5) AND #{@model_class.table_name}.id &gt; #{id}"</code><br />
whereas your code produces<br />
<code>"fresh = TRUE OR amount &gt; 5 AND #{@model_class.table_name}.id &gt; #{id}"</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: This Week in Ruby (May 20, 2008) &#124; Zen and the Art of Programming</title>
		<link>http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/#comment-28</link>
		<dc:creator>This Week in Ruby (May 20, 2008) &#124; Zen and the Art of Programming</dc:creator>
		<pubDate>Tue, 20 May 2008 22:20:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.flyingmachinestudios.com/?p=12#comment-28</guid>
		<description>[...] remarkable articles from this week were: Chunky Iterator: So You Don’t Have to Load All Your AR Objects at Once, Do we really need Controller and View tests?, Guide to Unobtrusive JavaScript and SWFUpload, [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] remarkable articles from this week were: Chunky Iterator: So You Don’t Have to Load All Your AR Objects at Once, Do we really need Controller and View tests?, Guide to Unobtrusive JavaScript and SWFUpload, [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl</title>
		<link>http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/#comment-20</link>
		<dc:creator>Karl</dc:creator>
		<pubDate>Wed, 14 May 2008 00:03:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.flyingmachinestudios.com/?p=12#comment-20</guid>
		<description>Looks like I had to do this again today, iterate/update over a large set. So I threw together a rake task to do such, but took a different route. Should be db independent, and doesn't depend on offsets.

I'm not saying it's better, just a different approach. Probably slower if a large percentage of the records need updates.

&lt;a href="http://blog.spoolz.com/2008/05/13/butt-biter-fix-state-abbreviations-large-data-set-updates/" rel="nofollow"&gt;http://blog.spoolz.com/2008/05/13/butt-biter-fix-state-abbreviations-large-data-set-updates/&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Looks like I had to do this again today, iterate/update over a large set. So I threw together a rake task to do such, but took a different route. Should be db independent, and doesn&#8217;t depend on offsets.</p>
<p>I&#8217;m not saying it&#8217;s better, just a different approach. Probably slower if a large percentage of the records need updates.</p>
<p><a href="http://blog.spoolz.com/2008/05/13/butt-biter-fix-state-abbreviations-large-data-set-updates/" rel="nofollow">http://blog.spoolz.com/2008/05/13/butt-biter-fix-state-abbreviations-large-data-set-updates/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2008-05-13, or so says Harry Love</title>
		<link>http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/#comment-19</link>
		<dc:creator>links for 2008-05-13, or so says Harry Love</dc:creator>
		<pubDate>Tue, 13 May 2008 16:31:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.flyingmachinestudios.com/?p=12#comment-19</guid>
		<description>[...] Flying Machine Studios » Blog Archive » Chunky Iterator: So You Don’t Have to Load All Your AR O... Iterate over a collection of AR objects in groups of n without having to load them all at once (tags: rubyonrails activerecord iterators)   Tags: Found Objects [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Flying Machine Studios » Blog Archive » Chunky Iterator: So You Don’t Have to Load All Your AR O&#8230; Iterate over a collection of AR objects in groups of n without having to load them all at once (tags: rubyonrails activerecord iterators)   Tags: Found Objects [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Higginbotham</title>
		<link>http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/#comment-17</link>
		<dc:creator>Daniel Higginbotham</dc:creator>
		<pubDate>Tue, 13 May 2008 13:42:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.flyingmachinestudios.com/?p=12#comment-17</guid>
		<description>Thanks for the great comments. I didn't realize that with limit/offset, query time can increase as offset gets larger. Thanks as well for the link to Jamis Buck's solution - it should be easy to combine what I have here with his solution so that the "cursored" find can take the other find options.

That's great that will_paginate has a method that will do this - before I wrote this post I was actually thinking that it would make sense to extend will_paginate to do this.  Looking through the code, it looks like the ActiveRecord#paginate method uses offset, so I guess paginated_each would also take increasing amounts of time.</description>
		<content:encoded><![CDATA[<p>Thanks for the great comments. I didn&#8217;t realize that with limit/offset, query time can increase as offset gets larger. Thanks as well for the link to Jamis Buck&#8217;s solution - it should be easy to combine what I have here with his solution so that the &#8220;cursored&#8221; find can take the other find options.</p>
<p>That&#8217;s great that will_paginate has a method that will do this - before I wrote this post I was actually thinking that it would make sense to extend will_paginate to do this.  Looking through the code, it looks like the ActiveRecord#paginate method uses offset, so I guess paginated_each would also take increasing amounts of time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Grant Hutchins</title>
		<link>http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/#comment-15</link>
		<dc:creator>Grant Hutchins</dc:creator>
		<pubDate>Tue, 13 May 2008 02:44:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.flyingmachinestudios.com/?p=12#comment-15</guid>
		<description>Recent versions of the will_paginate plugin include a method called paginated_each to do something similar.

http://groups.google.com/group/will_paginate/browse_thread/thread/59856834eb52b4d0</description>
		<content:encoded><![CDATA[<p>Recent versions of the will_paginate plugin include a method called paginated_each to do something similar.</p>
<p><a href="http://groups.google.com/group/will_paginate/browse_thread/thread/59856834eb52b4d0" rel="nofollow">http://groups.google.com/group/will_paginate/browse_thread/thread/59856834eb52b4d0</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evgeniy</title>
		<link>http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/#comment-14</link>
		<dc:creator>Evgeniy</dc:creator>
		<pubDate>Tue, 13 May 2008 02:34:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.flyingmachinestudios.com/?p=12#comment-14</guid>
		<description>solution can miss some records if inserts/deletes happening at the same time (even within block to process) - imagine you iterate to update or delete, on the next iteration - offset will jump over the last end

better to stick to Jamis Buck solution
http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord</description>
		<content:encoded><![CDATA[<p>solution can miss some records if inserts/deletes happening at the same time (even within block to process) - imagine you iterate to update or delete, on the next iteration - offset will jump over the last end</p>
<p>better to stick to Jamis Buck solution<br />
<a href="http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord" rel="nofollow">http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Jones</title>
		<link>http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/#comment-13</link>
		<dc:creator>Peter Jones</dc:creator>
		<pubDate>Tue, 13 May 2008 02:29:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.flyingmachinestudios.com/?p=12#comment-13</guid>
		<description>Looks a lot like my &lt;a href="http://pmade.com/svn/oss/all_records/trunk/lib/all_records.rb" rel="nofollow"&gt;all_records plugin&lt;/a&gt;.  Seems like this is a pretty universal need, and maybe should be in Rails?</description>
		<content:encoded><![CDATA[<p>Looks a lot like my <a href="http://pmade.com/svn/oss/all_records/trunk/lib/all_records.rb" rel="nofollow">all_records plugin</a>.  Seems like this is a pretty universal need, and maybe should be in Rails?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Wilden</title>
		<link>http://www.flyingmachinestudios.com/2008/05/12/chunky-iterator-so-you-dont-have-to-load-all-your-ar-objects-at-once/#comment-12</link>
		<dc:creator>Mark Wilden</dc:creator>
		<pubDate>Tue, 13 May 2008 01:44:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.flyingmachinestudios.com/?p=12#comment-12</guid>
		<description>Looks good. However, I'd DRY it up by using a do-while-do loop, so as to avoid duplicating the find call. Unfortunately, the only common language that supports that control structure (as far as I know) is Smalltalk, so you'd have to simulate it with code like:

 do
    find
    if not found
      break
   yield
   increment
 loop

///ark</description>
		<content:encoded><![CDATA[<p>Looks good. However, I&#8217;d DRY it up by using a do-while-do loop, so as to avoid duplicating the find call. Unfortunately, the only common language that supports that control structure (as far as I know) is Smalltalk, so you&#8217;d have to simulate it with code like:</p>
<p> do<br />
    find<br />
    if not found<br />
      break<br />
   yield<br />
   increment<br />
 loop</p>
<p>///ark</p>
]]></content:encoded>
	</item>
</channel>
</rss>
