- Home /
Are there any tips for speeding up SQLite through Unity on iOS
I have a SQLite database that's approximately 50mb (~23000 items) in size which I am using to store mesh data to be loaded into my Unity project. An UPDATE on that data when debugging through Unity on my mac takes approx. 1.5 sec. Running the same code on the device takes approx. 10 sec. Does anyone know of any particular reason why the same code would act so drastically different on the two platforms? Is it a mono thing? A device thing?
Aren't you comparing the performance of a low-power mobile CPU against a desktop or laptop CPU with multiple cores, a large cache that has had 30 years of development effort to make it crunch through data?
Yes. That's exactly what I'm comparing. And I suppose a SQLite expert could tell me that it's just the speed of the device. Or a $$anonymous$$ono expert could tell me that this is a known issue with $$anonymous$$ono on the iPhone. There are all sorts of apps out there that crunch SQLite data very quickly and it's one of apple's preferred ways to store data, so I would assume that for a relatively small select statement (in the grand scheme of things) performance should be better than what I'm getting.
They are using CoreData, not SQLite directly. Thats a day - night difference as apple opted CoreData to be invisible, smart and opted for the small to inexistent cashes that the mobile cpus have. Thats why you can crunch through programs with 200+ element listviews with detailed views behind it with images and movies etc all invisible with 20lines of code in Core Data at high performance and why the same in pure sqlite is gonna stutter like hell in basically any application.
Answer by ikeo · Aug 18, 2011 at 02:32 AM
I ended up figuring this out. I had forgotten to index my databases. I was also using Guids as my primary keys in several tables. After switching my primary keys to ints and indexing the databases, performance is about what I'd expect. The database can do lookups on 100k elements in under a second. That's fine for my purposes. This wasn't a unity or iOS problem, just a stupid programmer problem :)
Your answer
Follow this Question
Related Questions
sqlite plugin anomalies on ios 0 Answers
PtrToStructure with array fields on iOS (ie AOT only mode) 0 Answers
Mono.Data.Sqlite vs. System.Data.SQLite 2 Answers
How to calculate swipe speed on iOS 2 Answers