Core Data and Relationships

I've a large data feed to load in database. this data populate many entities that are related each others. I've follow this official tutorial to use nsbatchInsertRequest.
But this tutorial has one big bug: populate data only in one entity. How many apps use a database with only one entity?

therefore the problem that I have not only me, but several people, is time. With nsbatchinsertrequst I was able to insert more than 30000 records in just 5 seconds with a use of just 25MB of RAM. But without setting up relationships. if after the execution of the various insertrequests I set the relations, everything takes me about 50 seconds with an increase in memory to 60-70 MB.

Is it possible that there is no way to quickly set up relationships? Not only that, this is a forum where Apple engineers, who therefore know the subject better, should give help. but who knows why, for such questions they disappear. Maybe it's my posts that are so boring that Apple ignores them? Or are they so difficult that even apple engineers can't solve them? Who knows if I'll ever find the answer! But is it possible that they don't have a solution? These Apple engineers if they had the same problem as me, how would they solve it? they simply say: "it can't be done! Arrange!"?

anyway, I hope that some Apple engineer or someone experienced will be able to find the solution at least to this problem. Or it will be another zombie post in the billions of zombie posts of people like me who pay $ 100 but get no support.

Thank you
Post not yet marked as solved Up vote post of Rufy Down vote post of Rufy
1.4k views

Replies

Million dollar question, what’s certain is that batch requests don’t support relationships.
Post not yet marked as solved Up vote reply of awal Down vote reply of awal

Hey, Apple team, any updates on that topic?

Why does NSBatchInsertRequest do not provide any API for getting an internal context that is used for NSManagedObject creation:

https://developer.apple.com/documentation/coredata/nsbatchinsertrequest/3618791-init

It would be nice to have an access to NSManagedObject context here:

managedObjectHandler handler: @escaping (NSManagedObject, NSManagedObjectContext) -> Bool

So we could make add a relationship models just in place, without struggling with a workaround solutions.