Re: Improve performance of data structure saved to disk
Re: Improve performance of data structure saved to disk
- Subject: Re: Improve performance of data structure saved to disk
- From: Jens Alfke <email@hidden>
- Date: Thu, 06 Aug 2015 09:31:48 -0700
> On Aug 5, 2015, at 8:42 PM, Quincey Morris <email@hidden> wrote:
>
> IMO, Core Data is a terribly painful technology that will make you very, very miserable, not to mention adding many months to your project.
I’m not _quite_ as down on it, but my attempts to use it circa 2006-07 weren’t as successful as I’d have liked. It took a lot of work, a lot of things were unintuitive, and it didn’t scale well. (I’m sure there were ways to redesign my data or queries to scale better, but I couldn’t figure them out.)
> As an alternative, if your use case is really a kind of database, you could try using something like sqlite or couchDB (whatever it’s called now, I’m sure Jens would be happy to fill you in). If it’s not, write a custom data file and be done with it.
Yeah, I work on a mobile database called Couchbase Lite. It has an object-modeling layer that’s somewhat inspired by Core Data but with less complexity. On the other hand, Couchbase Lite’s primary feature is sync/replication, which ends up adding complexity of its own. I’d say that if all you want to do is locally persist a bunch of objects, it’s overkill.
As far as I know, there’s no good Cocoa solution for super-simple persistence — something like a persistent NSDictionary that can efficiently store any number of keys. This would be pretty easy to implement using a bare-bones key/value store like Berkeley DB, Tokyo Cabinet, LevelDB, LMDB, ForestDB, etc. (You can even use SQLite with a very simple key/value schema.) Just use the top-level dictionary key as the database key, and use NSCoding to persist the values as blobs. You wouldn’t get any query support, but for a lot of use cases you don’t need it.
(If anything like this does exist, let me know!)
Anyway, back to Juanjo’s question — I think I have to echo Uli and ask what the bottleneck is. Most likely you’ve got a lot of objects in your collection and it’s slow to read and write it. To some degree you can work around this by being careful not to save changes too often — throttle it so you wait a second after the change is made, and then you’ll be able to make one save for multiple changes. You can also do the write on a background thread/queue. But that’s just a band-aid.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden