This article was originally published on five.agency blog.

When importing large data sets, the primary goals are minimizing the memory usage, the duration of the import process, and keeping the work off the main thread as much as possible.

In this post we are going to explore the performance differences between two commonly used core data stacks on a large data set. For the purpose of this post, we will define a large data set as 300.000 entities consisting of two string attributes.

We are going to compare a stack where background context is a child of the main context, and the main context is connected to persistent store coordinator (aka nested contexts), and stack where background context and the main context are independent and both connected to persistent store coordinator (aka sibling contexts).