views:

14

answers:

1

I'm curious. Apple says in the docs:

Core Data automatically fires faults when necessary (when a persistent property of a fault is accessed). However, firing faults individually can be inefficient, and there are better strategies for getting data from the persistent store (see “Batch Faulting and Pre-fetching with the SQLite Store”).

NSFetchRequest has this feature:

[fetchRequest setFetchBatchSize:20];

Is this essentially performing such a batch faulting like recommended?

Just to make this clear for others, faulting does not mean "turning into a fault" but it means "materializing it", just like "making a Scooby-Doo out of it". Pretty ugly wording error, in my opinion, but it's at least consistent in the docs ;)

+3  A: 

The documentation answers that question, IMO:

If you set a non-zero batch size, the collection of objects returned when the fetch is executed is broken into batches. When the fetch is executed, the entire request is evaluated and the identities of all matching objects recorded, but no more than batchSize objects’ data will be fetched from the persistent store at a time. The array returned from executing the request will be a proxy object that transparently faults batches on demand. (In database terms, this is an in-memory cursor.)

That, to me, says that it divides the fetched results into batches that get faulted when any member of the batch is accessed.

Graham Lee