<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-1455593480232067247.post5187089181234706600..comments</id><updated>2010-03-19T14:07:00.783+02:00</updated><category term='User interface'/><category term='OpenMaps'/><category term='Reachability'/><category term='iphone'/><category term='NSOperationQueue'/><category term='Blocks'/><category term='Network Activity'/><category term='iOS 4'/><category term='Cocoa'/><category term='Core Data'/><category term='Asynchronous'/><category term='NSURLConnection'/><category term='Programming'/><category term='Growl'/><category term='NSOperation'/><category term='HTTP'/><title type='text'>Comments on blog.zssz.me: Asynchronous fetch in Core Data</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.zssz.me/feeds/5187089181234706600/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default'/><link rel='alternate' type='text/html' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html'/><author><name>Zsombor Szabo</name><uri>http://www.blogger.com/profile/00755069551354049151</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/-12NDsgnqgRc/TpA2H7k2yfI/AAAAAAAACLo/ZKo_3KBITec/s220/Bulgaria-Square.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1455593480232067247.post-6898185773876100634</id><published>2010-03-19T14:07:00.776+02:00</published><updated>2010-03-19T14:07:00.776+02:00</updated><title type='text'>I need to fetch some items in my code and hence it...</title><content type='html'>I need to fetch some items in my code and hence it takes time to load a&lt;br /&gt;particular view.Can I fetch them asyn in the background.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Can u please suggest me how to do this?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/6898185773876100634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/6898185773876100634'/><link rel='alternate' type='text/html' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html?showComment=1269000420776#c6898185773876100634' title=''/><author><name>Amrita Ghosh</name><uri>http://www.blogger.com/profile/11284798209559748659</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_zhJbzOGjakg/S0hN8LZOUgI/AAAAAAAAAIo/IffNSCsua2s/S220/photo-1.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html' ref='tag:blogger.com,1999:blog-1455593480232067247.post-5187089181234706600' source='http://www.blogger.com/feeds/1455593480232067247/posts/default/5187089181234706600' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-563800536'/></entry><entry><id>tag:blogger.com,1999:blog-1455593480232067247.post-3206696920885065184</id><published>2010-03-13T11:40:37.777+02:00</published><updated>2010-03-13T11:40:37.777+02:00</updated><title type='text'>I can&amp;#39;t think of a way how to do this with NSF...</title><content type='html'>I can&amp;#39;t think of a way how to do this with NSFetchedResultsController. It handles fetching internally.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/3206696920885065184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/3206696920885065184'/><link rel='alternate' type='text/html' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html?showComment=1268473237777#c3206696920885065184' title=''/><author><name>Zsombor Szabo</name><uri>http://www.blogger.com/profile/00755069551354049151</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_PHlCn60ls0c/SwcdSTg3hyI/AAAAAAAABo0/WJnxR2L5iKQ/S220/face-square2.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html' ref='tag:blogger.com,1999:blog-1455593480232067247.post-5187089181234706600' source='http://www.blogger.com/feeds/1455593480232067247/posts/default/5187089181234706600' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-631916921'/></entry><entry><id>tag:blogger.com,1999:blog-1455593480232067247.post-1957747246938711446</id><published>2010-03-13T10:57:36.643+02:00</published><updated>2010-03-13T10:57:36.643+02:00</updated><title type='text'>This is a great idea. Any tips on extending the NS...</title><content type='html'>This is a great idea. Any tips on extending the NSFetchedResultsController to make use of the async fetchrequests?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/1957747246938711446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/1957747246938711446'/><link rel='alternate' type='text/html' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html?showComment=1268470656643#c1957747246938711446' title=''/><author><name>Andy The Geek</name><uri>http://www.blogger.com/profile/16112347340953216977</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html' ref='tag:blogger.com,1999:blog-1455593480232067247.post-5187089181234706600' source='http://www.blogger.com/feeds/1455593480232067247/posts/default/5187089181234706600' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1709004984'/></entry><entry><id>tag:blogger.com,1999:blog-1455593480232067247.post-382929779154565297</id><published>2010-01-15T07:58:30.905+02:00</published><updated>2010-01-15T07:58:30.905+02:00</updated><title type='text'>Hi Zsombor, David here again.  I hope you don&amp;#39;...</title><content type='html'>Hi Zsombor, David here again.  I hope you don&amp;#39;t mind all the attention with your module.  It&amp;#39;s great work!&lt;br /&gt;&lt;br /&gt;I was able to use your code quite easily.  However, I have some interesting restrictions.  I want to perform asynchronous search for an iPhone app using UITableView, UISearchDisplayController, their data source delegates, and NSFetchedResultsController.  In theory, it should be straightforward to overlay a searchable interface on Core Data objects using these classes.&lt;br /&gt;&lt;br /&gt;In my case, I have a &amp;quot;main&amp;quot; entity with about 8400 instances.  My goal is to write a full text search for the text associated with each of these.  Therefore I&amp;#39;ve created an indexed searchWord entity that contains associations between a word and the main entity that contains that word.  There are about 57000 unique words linked to these 8400 main instances.  As you type, I retrieve all the main instances that have searchWords beginning with the prefix typed in the searchBar.  (E.g. the mail app provides this kind of text search.)&lt;br /&gt;&lt;br /&gt;Anyway, I&amp;#39;ve been surprised despite much model tweaking, messing around with predicates, and discussions elsewhere (http://stackoverflow.com/questions/1774369/how-to-optimize-core-data-query-for-full-text-search) that Core Data&amp;#39;s performance isn&amp;#39;t cutting it.  Thus, my desire to implement an async fetch.&lt;br /&gt;&lt;br /&gt;Because I&amp;#39;m using the NSFetchedResultsController I can&amp;#39;t call executeFetchRequestAsynchronously on the moc.  But that didn&amp;#39;t hurt me too badly.  I modified your code to pass the objectIds back.  I then gave a fetchRequest to the fetchedResultsController to retrieve the objects from the objectIds. &lt;br /&gt;&lt;br /&gt;The good news is that it works!  The bad news is that the async code is significantly slower.  Of course some overhead is expected because the fetch must be performed a second time to retrieve the objects.  But that extra hit was worse than I was hoping.  Typically on the iPhone 3GS the async search time was twice the time for blocking code.  Although the user interface didn&amp;#39;t block -- which is worth something!&lt;br /&gt;&lt;br /&gt;You can find a spreadsheet at http://drop.io/asyncCoreData .  The increase in running time versus blocked fetches and the increase in running time as a function of number of rows returned are both linear... which we would expect if the query was properly optimized and retrieving objects by objectId is O(N).  Unfortunately, in practice it&amp;#39;s still slow.&lt;br /&gt;&lt;br /&gt;An interesting example of this sluggish performance for searching large Core Data stores is Apple&amp;#39;s iTunes search interface on the iPhone.  (There&amp;#39;s a search bar hidden above the first row.)  I have over 6000 songs and the search is asynchronous, but appears snappy, through some tricks.  Even if you&amp;#39;ve chosen the &amp;quot;Songs&amp;quot; tab, the interface will search through artists, albums, and songs.  The implementation must be complicated, but the upshot is that when typing the first few characters you can immediately see the matches for artist or album and the song matches display after some delay further down the table.  Essentially Apple tricks you into thinking you&amp;#39;re getting a snappy result by showing easy matches first (artist and album) and filling in the matches for song titles later.&lt;br /&gt;&lt;br /&gt;Ultimately I&amp;#39;m just going to have to implement a limit on my query, but I&amp;#39;m really not happy about that.  From a UI experience, it&amp;#39;s lame.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/382929779154565297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/382929779154565297'/><link rel='alternate' type='text/html' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html?showComment=1263535110905#c382929779154565297' title=''/><author><name>d</name><uri>http://www.blogger.com/profile/07644039943363997714</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html' ref='tag:blogger.com,1999:blog-1455593480232067247.post-5187089181234706600' source='http://www.blogger.com/feeds/1455593480232067247/posts/default/5187089181234706600' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1441694882'/></entry><entry><id>tag:blogger.com,1999:blog-1455593480232067247.post-5898328271115894261</id><published>2010-01-12T06:28:24.260+02:00</published><updated>2010-01-12T06:28:24.260+02:00</updated><title type='text'>I think this problem is a little subtle.  I wonder...</title><content type='html'>I think this problem is a little subtle.  I wonder what those AJAX smarties do for their asynchronous network queries?&lt;br /&gt;&lt;br /&gt;You could easily imagine a situation that puts a heavy load on the database, which is already a problem for the iPhone.  E.g. I have a database of about 60000 rows and my queries on the ARM can take several sluggish seconds.  Thus, if cut-off time is 0.5s and query time averages 5s, then a user could trigger up to 10 concurrent queries.  (Note, [NSOperation cancel] does nothing unless the operation regularly checks isCanceled.)&lt;br /&gt;&lt;br /&gt;I think this may also be challenging on the iPhone with the conventional table search paradigm using the NSFetchedResultsController.  Early typing of one or a few keys will typically return larger result sets, which means passing around large arrays of object IDs.  Using the conventional executeFetchRequest, almost all the objects would remain faulted.  &lt;br /&gt;&lt;br /&gt;An array of, say, 60000 object IDs might require more  memory than the handful of in-memory objects from an array of 60000 NSManagedObjects that are mostly faulted??  Putting a limit on the query, though, is a reasonable option - although unfortunately requiring special handling to notify the user of truncated result set.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/5898328271115894261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/5898328271115894261'/><link rel='alternate' type='text/html' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html?showComment=1263270504260#c5898328271115894261' title=''/><author><name>d</name><uri>http://www.blogger.com/profile/07644039943363997714</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html' ref='tag:blogger.com,1999:blog-1455593480232067247.post-5187089181234706600' source='http://www.blogger.com/feeds/1455593480232067247/posts/default/5187089181234706600' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1441694882'/></entry><entry><id>tag:blogger.com,1999:blog-1455593480232067247.post-2923845944546219298</id><published>2010-01-11T18:59:52.004+02:00</published><updated>2010-01-11T18:59:52.004+02:00</updated><title type='text'>I suggest you to cancel any fetch if the user modi...</title><content type='html'>I suggest you to cancel any fetch if the user modifies the search string and issue a new fetch when there is no editing activity after e.g. 0.5 seconds.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/2923845944546219298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/2923845944546219298'/><link rel='alternate' type='text/html' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html?showComment=1263229192004#c2923845944546219298' title=''/><author><name>Zsombor Szabo</name><uri>http://www.blogger.com/profile/00755069551354049151</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_PHlCn60ls0c/SwcdSTg3hyI/AAAAAAAABo0/WJnxR2L5iKQ/S220/face-square2.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html' ref='tag:blogger.com,1999:blog-1455593480232067247.post-5187089181234706600' source='http://www.blogger.com/feeds/1455593480232067247/posts/default/5187089181234706600' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-631916921'/></entry><entry><id>tag:blogger.com,1999:blog-1455593480232067247.post-2386817863350172674</id><published>2010-01-11T08:57:50.759+02:00</published><updated>2010-01-11T08:57:50.759+02:00</updated><title type='text'>This couldn&amp;#39;t be better timed.  I&amp;#39;m amazed...</title><content type='html'>This couldn&amp;#39;t be better timed.  I&amp;#39;m amazed that Google caught your post so quickly!&lt;br /&gt;&lt;br /&gt;I just finished reading through Apple&amp;#39;s Core Data multi-threaded guidelines, looking at NSURLConnection&amp;#39;s initWithRequest:delegate:, and thinking to myself that this was how it should be done!&lt;br /&gt;&lt;br /&gt;I&amp;#39;m looking to implement real time search as you type.  Looking at your code I was first thinking of cancelling any previous fetches if a new key is pressed, but doing that would just discard, not interrupt, outstanding fetches.&lt;br /&gt;&lt;br /&gt;Any thoughts on how not to avoid congestion from multiple, simultaneous fetches?  Seems like the best approach would be to set a timer for, say, a 1/2 second before firing the async fetch.  The timer is invalidated if another key is pressed before the 1/2 second is up.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/2386817863350172674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1455593480232067247/5187089181234706600/comments/default/2386817863350172674'/><link rel='alternate' type='text/html' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html?showComment=1263193070759#c2386817863350172674' title=''/><author><name>d</name><uri>http://www.blogger.com/profile/07644039943363997714</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html' ref='tag:blogger.com,1999:blog-1455593480232067247.post-5187089181234706600' source='http://www.blogger.com/feeds/1455593480232067247/posts/default/5187089181234706600' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1441694882'/></entry></feed>
